/* ============================================================
   CSS Custom Properties — Dark Theme
   ============================================================ */
:root {
  --bg-primary:    #1a1a2e;   /* deepest background */
  --bg-secondary:  #16213e;   /* sidebar, cards */
  --bg-tertiary:   #0f3460;   /* input fields, elevated */
  --text-primary:  #e0e0e0;
  --text-secondary:#a0a0b0;
  --text-muted:    #60607a;
  --accent:        #e94560;   /* unread badge, active highlight */
  --accent-hover:  #c73652;
  --border:        #2a2a4a;
  --status-open:   #4caf50;   /* green */
  --status-replied:#2196f3;   /* blue */
  --status-closed: #9e9e9e;   /* gray */
  --bubble-in:     #2a2a3e;   /* incoming message */
  --bubble-out:    #0f3460;   /* outgoing message */
  --status-read:   #2196f3;   /* blue checkmarks */
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;  /* prevent horizontal scroll at any width */
}

/* ============================================================
   App Shell — two-panel layout with dvh
   ============================================================ */
.app-shell {
  display: flex;
  height: 100vh;       /* fallback */
  height: 100dvh;      /* iOS Safari: collapses with address bar */
  overflow: hidden;
}

/* ============================================================
   Chat Sidebar
   ============================================================ */
.chat-sidebar {
  width: 100%;         /* mobile: full width */
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  min-height: 56px;
}

.sidebar-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.monitor-status {
  font-size: 18px;
  color: var(--text-muted);
  cursor: default;
  transition: color 0.3s;
}

.search-wrapper {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); }

.chat-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   Chat List Item
   ============================================================ */
.chat-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  min-height: 44px;    /* touch-friendly */
  transition: background 0.15s;
  user-select: none;
}

.chat-item:hover, .chat-item:focus { background: var(--bg-tertiary); outline: none; }
.chat-item.active { background: var(--bg-tertiary); border-left: 3px solid var(--accent); }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.chat-item-body {
  flex: 1;
  min-width: 0;  /* allow text truncation */
}

.chat-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.chat-name {
  font-weight: 500;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.chat-time {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-item-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.chat-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.unread-badge {
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.chat-list-empty, .chat-list-loading {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================================
   Client Tag Badges & Score
   ============================================================ */
.client-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.client-tag--hot {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}
.client-tag--warm {
  background: rgba(255, 152, 0, 0.2);
  color: #ff9800;
}
.client-tag--cold {
  background: rgba(33, 150, 243, 0.2);
  color: #2196f3;
}
.client-score {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 2px;
  flex-shrink: 0;
}

/* ============================================================
   Client Notes (conversation header)
   ============================================================ */
.client-notes-wrapper {
  padding: 0 16px 8px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.client-notes {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
  padding: 6px 8px;
  resize: none;
  font-family: inherit;
  margin-top: 6px;
  line-height: 1.4;
  outline: none;
}
.client-notes:focus {
  border-color: var(--accent);
}
.client-notes::placeholder {
  color: var(--text-muted);
}

/* ============================================================
   Conversation Pane
   ============================================================ */
.conversation-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
}

/* Mobile: conversation hidden by default */
.conversation-pane {
  display: none;       /* mobile: hidden until chat selected */
}

.conversation-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 15px;
}

.conversation-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
}

.back-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

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

.conversation-client-info {
  flex: 1;
  min-width: 0;
}

.client-name {
  display: block;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-listing {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============================================================
   Messages Container + Bubbles
   ============================================================ */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.msg-bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.msg-in {
  background: var(--bubble-in);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.msg-out {
  background: var(--bubble-out);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.bubble-text { margin-bottom: 4px; }

.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.status-sent, .status-delivered { color: var(--text-muted); }
.status-read { color: var(--status-read); }

.load-more-indicator {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px;
  cursor: pointer;
}

/* ============================================================
   Reply Area
   ============================================================ */
.reply-area {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.template-strip {
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 8px 8px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.template-strip:empty { display: none; }
.template-strip::-webkit-scrollbar { display: none; }

.reply-input-row {
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 8px;
  align-items: flex-end;
}

.reply-textarea {
  flex: 1;
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  outline: none;
  min-height: 40px;
  max-height: 120px;
  overflow-y: auto;
}
.reply-textarea:focus { border-color: var(--accent); }
.reply-textarea::placeholder { color: var(--text-muted); }
.reply-textarea:disabled { opacity: 0.6; }

.send-btn {
  padding: 8px 16px;
  background: #2196f3;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  min-height: 40px;
  flex-shrink: 0;
  transition: background 0.2s, opacity 0.2s;
  white-space: nowrap;
}
.send-btn:hover:not(:disabled) { background: #1976d2; }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.send-btn.sent { background: #4caf50; }

.reply-error {
  color: var(--accent);
  font-size: 13px;
  padding: 0 8px 8px;
}

/* ============================================================
   Login Page
   ============================================================ */
.login-container {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-primary);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 28px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
  color: var(--text-primary);
}

.login-error {
  background: rgba(233, 69, 96, 0.15);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: block;
}

.login-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
}

.login-input:focus { border-color: var(--accent); }

.login-btn {
  margin-top: 8px;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.2s;
}

.login-btn:hover { background: var(--accent-hover); }

/* ============================================================
   Responsive — Tablet / Desktop (>=768px)
   ============================================================ */
@media (min-width: 768px) {
  .chat-sidebar {
    width: 320px;
    min-width: 280px;
    max-width: 360px;
  }

  /* Show conversation pane on tablet+ */
  .conversation-pane {
    display: flex;
  }

  /* Hide back button on tablet+ */
  .back-btn {
    display: none;
  }

  /* Mobile toggle classes — no-op on desktop */
  .hidden-mobile { display: flex !important; }
  .active-mobile { display: flex !important; }
}

/* ============================================================
   Mobile SPA toggle helpers (JS toggles these)
   ============================================================ */
.chat-sidebar.hidden-mobile { display: none; }
.conversation-pane.active-mobile { display: flex; }

/* ============================================================
   Template Buttons (quick reply strip)
   ============================================================ */
.template-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  padding: 4px 12px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.template-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ============================================================
   Settings Pages
   ============================================================ */
.settings-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 16px;
  color: var(--text-primary);
}

.settings-header {
  margin-bottom: 24px;
}

.settings-back-link {
  display: inline-block;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 12px;
}
.settings-back-link:hover { color: var(--text-primary); }

.settings-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.settings-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}
.settings-subtitle code {
  background: var(--bg-tertiary);
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 12px;
  color: var(--accent);
}

.settings-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

.settings-card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.settings-loading, .settings-empty {
  color: var(--text-muted);
  font-size: 14px;
  padding: 16px 0;
  text-align: center;
}

/* Settings form */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 600px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group-inline {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.form-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.form-input {
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
.form-input:focus { border-color: var(--accent); }
.form-input-sm { width: 80px; }

.form-textarea {
  padding: 8px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  resize: vertical;
  line-height: 1.5;
}
.form-textarea:focus { border-color: var(--accent); }
.form-textarea-sm { font-size: 13px; }

.form-error {
  color: var(--accent);
  font-size: 13px;
  margin-top: 8px;
}

/* Settings buttons */
.settings-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.settings-btn-primary {
  background: var(--accent);
  color: #fff;
}
.settings-btn-primary:hover { background: var(--accent-hover); }
.settings-btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.settings-btn-secondary:hover { color: var(--text-primary); }
.settings-btn-danger {
  background: rgba(233,69,96,0.15);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.settings-btn-danger:hover { background: rgba(233,69,96,0.25); }
.settings-btn-sm { padding: 4px 10px; font-size: 13px; }

/* Settings table */
.settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.settings-table th {
  text-align: left;
  padding: 8px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.settings-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.settings-table tr:last-child td { border-bottom: none; }
.td-position { width: 70px; color: var(--text-muted); }
.td-title { font-weight: 500; min-width: 120px; }
.td-body { color: var(--text-secondary); }
.td-actions { width: 170px; white-space: nowrap; }
.td-actions .settings-btn + .settings-btn { margin-left: 6px; }

/* ============================================================
   Monitor Log Page
   ============================================================ */
.monitor-page {
  max-width: 900px;
  margin: 0 auto;
  color: var(--text-primary);
}

.monitor-header {
  padding: 20px 16px 0;
}

.monitor-page-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.monitor-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.monitor-status-bar .status-dot {
  margin-top: 0;
  background: var(--text-secondary);
}

.status-dot--running { background: #22c55e !important; }
.status-dot--stopped { background: #ef4444 !important; }

#status-text {
  font-size: 14px;
  font-weight: 500;
}

#last-scan-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.log-timeline {
  display: flex;
  flex-direction: column;
}

.log-entry {
  display: flex;
  flex-direction: row;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  font-size: 0.85rem;
  align-items: baseline;
}

.log-entry--scan {
  color: var(--text-secondary);
}

.log-entry--message_found {
  background: rgba(34, 197, 94, 0.08);
}
.log-entry--message_found .log-entry__type {
  color: #22c55e;
}

.log-entry--filter_skip {
  background: rgba(234, 179, 8, 0.08);
}
.log-entry--filter_skip .log-entry__type {
  color: #eab308;
}

.log-entry--error {
  background: rgba(239, 68, 68, 0.12);
}
.log-entry--error .log-entry__type {
  color: #ef4444;
}

.log-entry__time {
  min-width: 140px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.log-entry__type {
  font-weight: 600;
  min-width: 100px;
  text-transform: uppercase;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.log-entry__details {
  flex: 1;
  word-break: break-word;
}

/* ============================================================
   AI Draft Card
   ============================================================ */
.ai-draft-card {
  margin: 8px 16px;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
}
.ai-draft-loading {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 16px;
}
.ai-draft-confidence-high { border-color: #4caf50; }
.ai-draft-confidence-medium { border-color: var(--border); }
.ai-draft-confidence-low { border-color: #ff9800; }

.ai-draft-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.ai-draft-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ai-draft-badge {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 32px;
  text-align: center;
}
.ai-draft-confidence-high .ai-draft-badge { background: rgba(76,175,80,0.2); color: #4caf50; }
.ai-draft-confidence-low .ai-draft-badge { background: rgba(255,152,0,0.2); color: #ff9800; }

.ai-draft-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  margin-bottom: 10px;
  white-space: pre-wrap;
}
.ai-draft-actions {
  display: flex;
  gap: 8px;
}
.ai-draft-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  transition: opacity 0.15s;
}
.ai-draft-btn:hover { opacity: 0.85; }
.ai-draft-send { background: #4caf50; color: #fff; }
.ai-draft-edit { background: #2196f3; color: #fff; }
.ai-draft-reject { background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border); }

/* ============================================================
   Autopilot Controls
   ============================================================ */
.autopilot-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.autopilot-segment {
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.autopilot-segment-btn {
  flex: 1;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.autopilot-segment-btn + .autopilot-segment-btn {
  border-left: 1px solid var(--border);
}
.autopilot-segment-btn.active {
  background: var(--accent);
  color: #fff;
}
.autopilot-segment-btn:hover:not(.active) {
  background: var(--bg-tertiary);
}

.autopilot-threshold {
  display: flex;
  align-items: center;
  gap: 8px;
}
.autopilot-threshold-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 72px;
}
.autopilot-slider {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
}

.autopilot-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}
.autopilot-pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4caf50;
  animation: pulse-green 1.5s infinite;
}
.autopilot-indicator-text {
  font-size: 11px;
  font-weight: 600;
  color: #4caf50;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Autopilot toast notification */
.autopilot-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 12px 20px;
  color: var(--text-primary);
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 9999;
  animation: toast-in 0.3s ease-out;
}
.autopilot-toast-hide {
  animation: toast-out 0.4s ease-in forwards;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(20px); }
}

/* Autopilot badge on auto-sent messages */
.msg-autopilot-badge {
  display: inline-block;
  font-size: 10px;
  background: rgba(76,175,80,0.2);
  color: #4caf50;
  border-radius: 4px;
  padding: 1px 4px;
  margin-left: 4px;
  font-weight: 500;
}

/* ============================================================
   Autopilot Feed Page
   ============================================================ */
.autopilot-feed-page {
  max-width: 900px;
  margin: 0 auto;
  padding-bottom: 40px;
}

.autopilot-timeline {
  padding: 0 16px;
}

.autopilot-entry {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  transition: opacity 0.3s;
}
.autopilot-entry--cancelled {
  opacity: 0.6;
}

.autopilot-entry__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.autopilot-entry__client {
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}
.autopilot-entry__client:hover {
  text-decoration: underline;
}
.autopilot-entry__time {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.autopilot-entry__text {
  font-size: 14px;
  white-space: pre-wrap;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 10px;
  max-height: 120px;
  overflow: hidden;
}
.autopilot-text--cancelled {
  text-decoration: line-through;
  color: var(--text-secondary);
}

.autopilot-expand-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 0;
  margin-top: 4px;
}
.autopilot-expand-btn:hover {
  text-decoration: underline;
}

.autopilot-entry__footer {
  display: flex;
  align-items: center;
  gap: 10px;
}

.autopilot-confidence-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  padding: 2px 8px;
}

.autopilot-status {
  font-size: 12px;
  font-weight: 500;
}
.autopilot-status--sent {
  color: var(--status-open);
}
.autopilot-status--cancelled {
  color: var(--text-muted);
}

.autopilot-cancel-btn {
  margin-left: auto;
}
.autopilot-cancel-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Semi mode dot */
.status-dot--semi {
  background: #ff9800;
  box-shadow: 0 0 6px rgba(255, 152, 0, 0.5);
}

/* ============================================================
   Analytics Page
   ============================================================ */
.analytics-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px;
  color: var(--text-primary);
}

.analytics-header {
  padding: 0 0 12px;
}

.period-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.period-btn {
  flex: 0 0 auto;
  padding: 6px 16px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.period-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.period-btn:hover:not(.active) {
  background: var(--bg-tertiary);
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stats-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.stats-card__title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-card__metrics {
  display: flex;
  gap: 16px;
}

.stats-card__metric {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
}
.stats-card__metric span {
  color: var(--text-primary);
  font-weight: 600;
}

.stats-unavailable {
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
  font-size: 14px;
}

.chart-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.chart-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

.analytics-page canvas {
  max-height: 300px;
}
