/* ===== Base ===== */
:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --border: #e4e6eb;
  --text: #1c1e21;
  --text-muted: #65676b;
  --text-light: #8a8d91;
  --primary: #0084ff;
  --primary-hover: #0070db;
  --green: #00a884;
  --red: #e74c3c;
  --orange: #f39c12;
  --yellow: #ffc107;
  --purple: #8e44ad;
  --msg-in: #ffffff;
  --msg-out: #e7f3ff;
  --sidebar-w: 320px;
  --right-w: 340px;
  --topbar-h: 50px;
  --radius: 10px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; }
input, select, textarea, button { font-family: var(--font); font-size: 13px; }

/* ===== Top Bar ===== */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--primary);
  color: #fff;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand-logo { font-size: 22px; }
.brand b { font-size: 15px; }
.muted { color: rgba(255,255,255,0.7); }
.small { font-size: 12px; }
.btn-ghost {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}
.btn-ghost:hover { background: rgba(255,255,255,0.25); }

/* ===== 3-Panel Layout ===== */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--right-w);
  height: calc(100vh - var(--topbar-h));
}

/* ===== Left Panel: Thread List ===== */
.panel-left {
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-header { padding: 10px; border-bottom: 1px solid var(--border); }
.sidebar-header input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  outline: none;
  background: var(--bg);
  font-size: 13px;
}
.sidebar-header input:focus { border-color: var(--primary); background: #fff; }
.filters { display: flex; gap: 6px; margin-top: 8px; }
.filters select {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
}
.filters-extra { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.filters-extra select {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
}
.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.filter-checkbox input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}

.thread-list { overflow-y: auto; flex: 1; }
.thread-item {
  padding: 10px 12px;
  border-bottom: 1px solid #f5f5f5;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.thread-item:hover { background: #f8f9fa; }
.thread-item .line1 { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.thread-item .name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.thread-item .badges { display: flex; gap: 4px; flex-shrink: 0; }
.thread-item .badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-urgent { background: #ffebee; color: #c62828; animation: pulse 2s infinite; }
.badge-kept { background: #e3f2fd; color: #1565c0; font-size: 9px; }
.badge-pending-order { background: #fff3e0; color: #e65100; font-size: 9px; }
.badge-follow-up { background: #fff8e1; color: #f57f17; font-size: 9px; }
.badge-denied { background: #fce4ec; color: #c62828; font-size: 9px; }
.badge-blocked { background: #ffebee; color: #c62828; font-size: 9px; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* Follow-up toggle (same pattern as pending-order) */
.follow-up-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.follow-up-toggle input[type="checkbox"] { cursor: pointer; }
.follow-up-label { color: var(--text-muted); font-weight: 500; }
.follow-up-toggle input:checked + .follow-up-label { color: #f57f17; font-weight: 600; }

/* Done toggle (same pattern as follow-up) */
.done-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.done-toggle input[type="checkbox"] { cursor: pointer; }
.done-label { color: var(--text-muted); font-weight: 500; }
.done-toggle input:checked + .done-label { color: #2e7d32; font-weight: 600; }

/* Compact mode toggle (per-user, hides call recordings in chat) */
.compact-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.compact-toggle input[type="checkbox"] { cursor: pointer; }
.compact-label { color: var(--text-muted); font-weight: 500; }
.compact-toggle input:checked + .compact-label { color: #5c6bc0; font-weight: 600; }

/* When compact mode is active, hide call entries in the chat timeline */
body.compact-mode .msg.call-entry { display: none !important; }

/* Empty message state */
.msg-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  animation: welcomeFadeIn 0.4s ease-out;
}
.msg-empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.6; }
.msg-empty-title { font-size: 16px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; }
.msg-empty-desc { font-size: 13px; color: var(--text-light); line-height: 1.6; max-width: 320px; }

.sentiment-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0;
}
.sentiment-positive { background: var(--green); }
.sentiment-neutral { background: #bbb; }
.sentiment-negative { background: var(--orange); }
.sentiment-angry { background: var(--red); }

.thread-item .preview {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-item .meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-light);
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ===== Center Panel: Chat ===== */
.panel-center {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

/* Chat area wrapper (visible when thread selected) */
.chat-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ===== Welcome Intro Screen ===== */
.welcome-intro {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #fafbff 0%, #f0f4ff 50%, #e8eeff 100%);
  position: relative;
  overflow: hidden;
}
.welcome-intro::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(102, 126, 234, 0.06) 0%, transparent 70%);
  pointer-events: none;
}
.welcome-intro::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(118, 75, 162, 0.05) 0%, transparent 70%);
  pointer-events: none;
}
.welcome-content {
  text-align: center;
  z-index: 1;
  animation: welcomeFadeIn 0.6s ease-out;
}
@keyframes welcomeFadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.welcome-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}
.welcome-logo-ring {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  padding: 3px;
  animation: logoSpin 12s linear infinite;
}
@keyframes logoSpin {
  0% { background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%); }
  33% { background: linear-gradient(135deg, #f093fb 0%, #667eea 50%, #764ba2 100%); }
  66% { background: linear-gradient(135deg, #764ba2 0%, #f093fb 50%, #667eea 100%); }
  100% { background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%); }
}
.welcome-logo-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}
.welcome-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 6px;
}
.welcome-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 28px;
  font-weight: 400;
  letter-spacing: 0.2px;
}
.welcome-divider {
  width: 40px;
  height: 2px;
  background: linear-gradient(90deg, #667eea, #764ba2);
  margin: 0 auto 28px;
  border-radius: 2px;
}
.welcome-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 320px;
  margin: 0 auto 32px;
}
.welcome-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(102, 126, 234, 0.08);
  transition: transform 0.2s, box-shadow 0.2s;
}
.welcome-feature:hover {
  transform: translateX(4px);
  box-shadow: 0 2px 12px rgba(102, 126, 234, 0.1);
}
.wf-icon {
  font-size: 20px;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.08));
}
.wf-text {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  text-align: left;
}
.welcome-hint {
  font-size: 12px;
  color: var(--text-light);
  margin: 0;
  letter-spacing: 0.3px;
}

.thread-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 52px;
}
.thread-header-left { overflow: hidden; }
.thread-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-meta { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.thread-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.thread-actions select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: #fff; font-size: 12px; }

/* Add Friend Button */
.btn-add-friend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  background: linear-gradient(135deg, #00a884, #25d366);
  border: none;
  color: #fff;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(0,168,132,0.3);
}
.btn-add-friend:hover:not(:disabled) {
  background: linear-gradient(135deg, #009975, #20c55e);
  box-shadow: 0 3px 10px rgba(0,168,132,0.4);
  transform: translateY(-1px);
}
.btn-add-friend:disabled {
  opacity: 0.7;
  cursor: default;
  transform: none;
  box-shadow: none;
}
.btn-add-friend-sent {
  background: linear-gradient(135deg, #43a047, #66bb6a) !important;
}

/* Unified Threads: Account Badges */
.account-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: 0.3px;
  line-height: 16px;
}
.account-badge:nth-child(2) { background: linear-gradient(135deg, #f093fb, #f5576c); }
.account-badge:nth-child(3) { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.account-badge.unified-count {
  background: linear-gradient(135deg, #43e97b, #38f9d7);
  color: #1a4a3a;
}
.account-badge.account-badge-oa {
  background: linear-gradient(135deg, #0068ff, #0099ff);
  color: #fff;
}

/* OA 48h CS Window Warning */
.oa-window-warning {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  border-radius: 6px;
  margin: 4px 12px;
}
.oa-window-warning-urgent {
  background: #fff8e1;
  border: 1px solid #ffcc02;
  color: #7a6200;
}
.oa-window-expired {
  background: #fce4ec;
  border: 1px solid #e57373;
  color: #b71c1c;
}

/* Thread header: accounts row */
.thread-accounts {
  display: flex;
  gap: 4px;
  margin-top: 2px;
  align-items: center;
  flex-wrap: wrap;
}

/* Message account badge (shown on each message in unified threads) */
.msg-account-badge {
  display: inline-block;
  padding: 0 5px;
  border-radius: 6px;
  font-size: 9px;
  font-weight: 600;
  background: rgba(102, 126, 234, 0.15);
  color: #667eea;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 15px;
}
.msg.out .msg-account-badge {
  background: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.9);
}

/* Account selector in composer */
.account-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: linear-gradient(135deg, #f0f4ff, #e8ecff);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.account-selector label {
  font-weight: 600;
  color: #667eea;
  white-space: nowrap;
}
.account-selector select {
  padding: 4px 8px;
  border: 1px solid #667eea;
  border-radius: 6px;
  background: #fff;
  color: #333;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.account-selector select:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 12px;
}
.btn-outline:hover { background: #f5f5f5; }

.btn-primary {
  background: var(--primary);
  border: none;
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.btn-primary:hover { background: var(--primary-hover); }

/* Tag bar */
.tag-bar {
  background: var(--surface);
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
}
.tag-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag-chip {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 500;
}
.tag-intent { background: #e3f2fd; color: #1565c0; }
.tag-sentiment-positive { background: #e8f5e9; color: #2e7d32; }
.tag-sentiment-neutral { background: #f5f5f5; color: #616161; }
.tag-sentiment-negative { background: #fff3e0; color: #e65100; }
.tag-sentiment-angry { background: #ffebee; color: #c62828; }
.tag-urgency { background: #fce4ec; color: #ad1457; }

/* Messages */
.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  position: relative;
}
.msg.in {
  align-self: flex-start;
  background: var(--msg-in);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg.out {
  align-self: flex-end;
  background: var(--msg-out);
  border: 1px solid #c6dff7;
  border-bottom-right-radius: 4px;
}
.msg .sender { font-size: 11px; color: var(--primary); font-weight: 600; margin-bottom: 2px; }
.msg .content { white-space: pre-wrap; word-break: break-word; }
.msg .time { font-size: 10px; color: var(--text-light); margin-top: 4px; text-align: right; }

/* Message highlight animation (scroll-to from summary) */
.msg-highlight {
  animation: msgHighlightPulse 3s ease-out forwards;
}
@keyframes msgHighlightPulse {
  0% { box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.7), 0 0 16px rgba(255, 193, 7, 0.4); }
  30% { box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.5), 0 0 12px rgba(255, 193, 7, 0.3); }
  100% { box-shadow: none; }
}

/* ===== Call Card in Chat Timeline (VC-12) ===== */
.msg.call-entry {
  align-self: center;
  max-width: 88%;
  width: 520px;
  padding: 0;
  border-radius: 14px;
  border: 1px solid rgba(102, 126, 234, 0.2);
  background: linear-gradient(135deg, #f8faff 0%, #f0f4ff 100%);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.08);
  margin: 8px auto;
  animation: callCardIn 0.3s ease-out;
}
@keyframes callCardIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}
.call-card {
  padding: 14px 16px;
}
.call-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.call-card-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.call-card-title {
  font-weight: 700;
  font-size: 13px;
  color: #4a5568;
}
.call-card-agent {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: #667eea;
  background: rgba(102, 126, 234, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
}
.call-card-summary {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  border-left: 3px solid #667eea;
}
.call-card-pending {
  color: var(--text-light);
  font-style: italic;
  border-left-color: #ffc107;
}
.call-card-topics {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.call-topic-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
  color: #2e7d32;
  font-weight: 500;
}
.call-card-audio {
  margin: 8px 0;
}
.call-card-audio audio {
  width: 100%;
  height: 36px;
  border-radius: 18px;
}
.call-card-transcript {
  margin-top: 8px;
  border-radius: 10px;
  overflow: hidden;
}
.call-card-transcript summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  transition: background 0.15s;
  list-style: none;
  user-select: none;
}
.call-card-transcript summary::-webkit-details-marker { display: none; }
.call-card-transcript summary::before {
  content: '▸ ';
  display: inline;
  transition: transform 0.2s;
}
.call-card-transcript[open] summary::before { content: '▾ '; }
.call-card-transcript summary:hover { background: rgba(255, 255, 255, 0.8); }
.call-segments {
  max-height: 260px;
  overflow-y: auto;
  padding: 8px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.call-seg {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.5;
  border-radius: 8px;
}
.call-seg-time {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-light);
  min-width: 28px;
  padding-top: 2px;
  font-variant-numeric: tabular-nums;
}
.call-seg-label {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 11px;
  min-width: 42px;
}
.call-seg-text {
  flex: 1;
  color: var(--text);
  word-break: break-word;
}
.call-seg.seg-agent {
  background: rgba(102, 126, 234, 0.06);
}
.call-seg.seg-agent .call-seg-label { color: #667eea; }
.call-seg.seg-customer {
  background: rgba(0, 168, 132, 0.06);
}
.call-seg.seg-customer .call-seg-label { color: #00a884; }
.msg.call-entry .time {
  text-align: center;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* Composer */
.composer {
  position: relative;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.composer textarea {
  flex: 1;
  resize: none;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  outline: none;
  background: var(--bg);
  line-height: 1.5;
  min-height: calc(2 * 1.5em + 20px); /* 2 lines + padding */
  max-height: calc(10 * 1.5em + 20px); /* 10 lines + padding */
  overflow-y: auto;
  transition: height 0.15s ease;
}
.composer textarea:focus { border-color: var(--primary); background: #fff; }

/* Clipboard paste overlay */
.composer-paste-overlay {
  position: absolute;
  inset: 0;
  background: rgba(102, 126, 234, 0.08);
  border: 2px dashed var(--primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  animation: pasteOverlayIn 0.2s ease;
}
@keyframes pasteOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.composer-paste-overlay-text {
  background: var(--primary);
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Paste preview banner */
.paste-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #f0f7ff, #e8f0ff);
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: 8px;
  margin-bottom: 8px;
  animation: slideDown 0.2s ease;
  font-size: 12px;
}
.paste-preview-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.paste-preview-info {
  flex: 1;
  min-width: 0;
}
.paste-preview-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.paste-preview-meta {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 1px;
}
.paste-preview-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.paste-preview-actions button {
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.paste-preview .btn-paste-send {
  background: var(--primary);
  color: #fff;
}
.paste-preview .btn-paste-send:hover {
  background: var(--primary-hover);
}
.paste-preview .btn-paste-cancel {
  background: #f5f5f5;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.paste-preview .btn-paste-cancel:hover {
  background: #eee;
}
.paste-preview-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.composer-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.composer-actions button {
  background: var(--primary);
  border: none;
  color: #fff;
  padding: 10px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.composer-actions button:hover { background: var(--primary-hover); }

/* ===== Right Panel: Tabs ===== */
.panel-right {
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.right-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab-btn {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab-btn:hover { background: #f8f9fa; }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #f0f7ff;
}

/* Overflow tab button */
.tab-overflow-wrapper {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
}
.tab-overflow-btn {
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 700;
  font-size: 16px;
  border-bottom: 2px solid transparent;
  border-left: 1px solid var(--border);
  transition: all 0.2s;
  letter-spacing: 2px;
}
.tab-overflow-btn:hover { background: #f8f9fa; color: var(--text); }
.tab-overflow-btn.has-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #f0f7ff;
}

/* Overflow dropdown menu */
.tab-overflow-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 100;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  overflow: hidden;
  animation: overflowSlideDown 0.15s ease-out;
}
.tab-overflow-menu.show { display: block; }
@keyframes overflowSlideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.tab-overflow-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background 0.15s;
  white-space: nowrap;
}
.tab-overflow-item:hover { background: #f0f7ff; color: var(--primary); }
.tab-overflow-item + .tab-overflow-item { border-top: 1px solid var(--border); }

/* Active overflow tab indicator (replaces ⋯ button with tab info) */
.tab-overflow-active-label {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 12px 10px;
  border-bottom: 2px solid var(--primary);
  background: #f0f7ff;
  color: var(--primary);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}
.tab-overflow-active-label.show { display: flex; }
.tab-overflow-active-label .tab-close {
  font-size: 14px;
  opacity: 0.5;
  margin-left: 2px;
}
.tab-overflow-active-label .tab-close:hover { opacity: 1; }

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.tab-content.active { display: flex; flex-direction: column; }

/* ===== Internal Files Browser ===== */
.files-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 8px;
}
.files-header {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  padding: 0 0 4px;
}
.files-search-row {
  display: flex;
  gap: 6px;
}
.files-search-row input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  outline: none;
}
.files-search-row input:focus { border-color: var(--primary); }
.files-search-row select {
  min-width: 90px;
  padding: 7px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--surface);
  cursor: pointer;
}

/* Selected files action bar */
.files-selected-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #e3f2ff 0%, #f0f7ff 100%);
  border: 1px solid var(--primary);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  animation: selectedBarPop 0.2s ease-out;
}
@keyframes selectedBarPop {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.files-selected-bar span { flex: 1; }

/* File list */
.files-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.files-empty {
  text-align: center;
  padding: 30px 16px;
  color: var(--text-muted);
  font-size: 13px;
}
.files-empty .files-empty-icon { font-size: 32px; margin-bottom: 6px; }

/* File card */
.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.file-card:hover {
  border-color: var(--primary);
  background: #f8fbff;
}
.file-card.selected {
  border-color: var(--primary);
  background: #e3f2ff;
}
.file-card-check {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-size: 11px;
  color: transparent;
}
.file-card.selected .file-card-check {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.file-card-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f7fa;
  border-radius: 8px;
}
.file-card-thumb {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.file-card-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.file-card-name {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-card-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}
.file-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-card-category {
  display: inline-block;
  padding: 1px 6px;
  background: #f0f7ff;
  color: var(--primary);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

/* Empty states */
.empty-state { text-align: center; padding: 40px 16px; }
.empty-icon { font-size: 40px; margin-bottom: 8px; }
.empty-text { color: var(--text-muted); font-size: 13px; }

/* Loading */
.loading-state { text-align: center; padding: 40px 16px; color: var(--text-muted); }
.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Copilot Sections ===== */
.cp-section { margin-bottom: 14px; }
.cp-label { font-weight: 700; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.cp-summary {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  line-height: 1.5;
  border-left: 3px solid var(--primary);
}
.cp-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.cp-chip {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 600;
}
.cp-tools { display: flex; flex-direction: column; gap: 6px; }
.cp-tool {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #f8f9fa;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
}
.cp-tool:hover { background: #e7f3ff; border-color: var(--primary); }
.cp-tool-icon { font-size: 16px; }

.cp-products { display: flex; flex-direction: column; gap: 6px; }
.cp-product {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
}
.cp-product .p-name { font-weight: 600; }
.cp-product .p-code { color: var(--text-light); font-size: 11px; }
.cp-product .p-stock { color: var(--green); font-weight: 500; }

.cp-hint { font-size: 11px; color: var(--text-light); margin-bottom: 6px; }
.cp-replies { display: flex; flex-direction: column; gap: 6px; }
.cp-reply {
  background: #f0f7ff;
  border: 1px solid #c6dff7;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.5;
}
.cp-reply:hover { background: #d6eaff; border-color: var(--primary); }

.cp-refresh {
  width: 100%;
  margin-top: 8px;
}

/* ===== Profile Form ===== */
.profile-form { display: flex; flex-direction: column; gap: 10px; }
.pf-group { display: flex; flex-direction: column; gap: 3px; }
.pf-group label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.pf-group input, .pf-group textarea, .pf-group select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  font-size: 13px;
}
.pf-group input:focus, .pf-group textarea:focus { border-color: var(--primary); }
.pf-group textarea { resize: vertical; }
.pf-row { display: flex; gap: 8px; }
.pf-row .pf-group { flex: 1; }
.pf-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 24px;
}
.pf-tag {
  font-size: 11px;
  background: #e8f5e9;
  color: #2e7d32;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 500;
}
.pf-save { margin-top: 6px; width: 100%; }
.pf-save-status { font-size: 12px; text-align: center; margin-top: 4px; }
.pf-save-status.ok { color: var(--green); }
.pf-save-status.err { color: var(--red); }

.pf-ai-info {
  background: #f5f0ff;
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.6;
  border-left: 3px solid var(--purple);
}

/* ===== Login page ===== */
.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: linear-gradient(135deg, #0084ff 0%, #7c4dff 100%);
}
.card {
  width: 400px;
  max-width: 95vw;
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.card h1 { margin: 0 0 6px 0; color: var(--primary); }
.card .subtitle { color: var(--text-muted); margin-bottom: 16px; font-size: 13px; }
.card label { display: block; margin-top: 12px; font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.card input {
  width: 100%;
  margin-top: 6px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  font-size: 14px;
}
.card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,132,255,0.1); }
.card button {
  margin-top: 18px;
  width: 100%;
  background: var(--primary);
  border: none;
  color: #fff;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
}
.card button:hover { background: var(--primary-hover); }

.error {
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  background: #fff0f0;
  border: 1px solid #ffd0d0;
  color: #900;
  font-size: 13px;
}

.card .help { margin-top: 12px; font-size: 12px; color: var(--text-light); text-align: center; }
.card .help code { background: #f5f5f5; padding: 2px 6px; border-radius: 4px; font-size: 11px; }

/* ===== Phone Search ===== */
.search-phone-row {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}
.search-phone-row input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  background: var(--bg);
}
.search-phone-row input:focus { border-color: var(--primary); background: #fff; }
.search-phone-row button {
  padding: 6px 10px;
  font-size: 11px;
  white-space: nowrap;
}

/* Cloud save toggle */
.cloud-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 16px;
}
.cloud-toggle input { display: none; }
.cloud-toggle .cloud-label { opacity: 0.4; transition: opacity 0.2s; }
.cloud-toggle input:checked + .cloud-label { opacity: 1; }

/* Attach button */
.btn-attach {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.btn-attach:hover { background: #f0f7ff; border-color: var(--primary); }

/* Media messages */
.msg-media img {
  max-width: 240px;
  max-height: 200px;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 4px;
}
.msg-media img:hover { opacity: 0.9; }
.msg-media-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}
.msg-audio { margin-top: 4px; }
.msg-audio audio { max-width: 220px; height: 36px; }

/* Phone search results modal */
.phone-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
}
.phone-result-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid #f5f5f5;
  display: flex;
  align-items: center;
  gap: 8px;
}
.phone-result-item:hover { background: #f0f7ff; }
.phone-result-item img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}
.phone-result-name { font-weight: 600; }
.phone-result-id { font-size: 11px; color: var(--text-light); }

/* Upload progress */
.upload-progress {
  background: var(--bg);
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Template Panel ===== */
.template-panel {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  max-height: 200px;
  overflow-y: auto;
}
.template-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 6px;
  color: var(--text-muted);
}
.btn-ghost-sm {
  background: transparent;
  border: none;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-light);
  padding: 2px 6px;
  border-radius: 4px;
}
.btn-ghost-sm:hover { background: #f0f0f0; }
.template-list { display: flex; flex-direction: column; gap: 4px; }
.template-item {
  padding: 8px 10px;
  background: #f0f7ff;
  border: 1px solid #c6dff7;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.template-item:hover { background: #d6eaff; border-color: var(--primary); }
.template-label { font-weight: 600; margin-bottom: 2px; }
.template-preview { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Profile actions row */
.pf-actions { display: flex; gap: 6px; margin-top: 6px; }
.pf-actions button { flex: 1; }

/* ===== Avatar Styles ===== */
.thread-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
}
.thread-avatar-fallback {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #e0e7ff, #dbeafe);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.thread-avatar-fallback-lg {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #e0e7ff, #dbeafe);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.thread-avatar-header {
  flex-shrink: 0; margin-right: 8px;
}
.thread-avatar-header img {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
}
.thread-item-row {
  display: flex; gap: 10px; align-items: flex-start;
}
.thread-item-info { flex: 1; min-width: 0; }

/* Profile avatar section */
.pf-avatar-section {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border); margin-bottom: 10px;
}
.pf-avatar-img {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; background: linear-gradient(135deg, #e0e7ff, #dbeafe);
  overflow: hidden; flex-shrink: 0;
}
.pf-avatar-img img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.pf-avatar-info { flex: 1; }
.pf-zalo-name { font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 4px; }

/* ===== Media Rendering ===== */
.msg-img-thumb {
  max-width: 240px; max-height: 240px;
  border-radius: 8px; cursor: pointer;
  transition: opacity 0.2s;
}
.msg-img-thumb:hover { opacity: 0.85; }
.msg-video {
  max-width: 280px; max-height: 200px;
  border-radius: 8px;
}
.msg-audio-player {
  display: flex; flex-direction: column; gap: 4px;
}
.msg-audio-el {
  max-width: 240px; height: 36px;
}
.btn-stt {
  font-size: 11px; padding: 3px 8px;
  background: #f0f7ff; border: 1px solid #c6dff7;
  border-radius: 12px; cursor: pointer;
  align-self: flex-start;
  transition: all 0.15s;
}
.btn-stt:hover { background: #d6eaff; }
.stt-result {
  font-size: 12px; color: var(--text-muted); padding: 4px 8px;
  background: #fafafa; border-radius: 6px;
  border: 1px dashed var(--border); margin-top: 2px;
}
.stt-result.stt-auto {
  background: #f0f7ff;
  border: none;
  border-left: 3px solid var(--primary);
  padding: 6px 10px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
.img-desc-result {
  font-size: 12px;
  color: var(--text);
  padding: 6px 10px;
  background: #f0faf0;
  border: none;
  border-left: 3px solid #43a047;
  margin-top: 6px;
  border-radius: 0 6px 6px 0;
  line-height: 1.5;
}

/* ===== Product Recognition Card (under image) ===== */
.img-product-card {
  margin-top: 6px;
  padding: 8px 10px;
  background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
  border-left: 3px solid #43a047;
  border-radius: 0 8px 8px 0;
  line-height: 1.5;
}
.img-product-card.img-product-maybe {
  background: linear-gradient(135deg, #fff3e0 0%, #fff8e1 100%);
  border-left-color: #f57c00;
}
.img-product-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.img-product-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  background: #43a047;
  color: #fff;
  white-space: nowrap;
}
.img-product-badge.maybe {
  background: #f57c00;
}
.img-product-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.img-product-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.msg-sticker { max-width: 120px; max-height: 120px; }
.msg-caption {
  font-size: 13px;
  color: var(--text);
  padding: 4px 0 0;
  line-height: 1.4;
}

/* ===== Contact Card ===== */
.msg-contact-card {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 12px; border-radius: 10px;
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border: 1px solid #dee2e6;
  max-width: 280px;
}
.contact-card-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
}
.contact-card-info { flex: 1; }
.contact-card-name { font-weight: 600; font-size: 13px; color: var(--text); }
.contact-card-phone { font-size: 12px; color: var(--primary); margin-top: 2px; }
.contact-card-link {
  font-size: 11px; color: var(--primary); text-decoration: none; margin-top: 2px; display: block;
}
.contact-card-link:hover { text-decoration: underline; }

/* ===== Recommended Card (generic chat.recommended) ===== */
.msg-recommended-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e0e0e0;
  background: linear-gradient(135deg, #f5f7fa 0%, #eef1f5 100%);
  max-width: 320px;
  transition: box-shadow 0.2s;
}
.msg-recommended-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.msg-recommended-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #e0e0e0;
}
.msg-recommended-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  flex-shrink: 0;
}
.msg-recommended-body {
  flex: 1;
  min-width: 0;
}
.msg-recommended-action {
  font-size: 10px;
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}
.msg-recommended-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-recommended-desc {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}
.msg-recommended-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  flex-shrink: 0;
  transition: background 0.2s;
}
.msg-recommended-link:hover { background: var(--primary-hover); }

/* ===== Location Message ===== */
.msg-location {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #dee2e6;
  max-width: 300px;
  background: #fff;
}
.msg-location-map {
  width: 100%;
  height: 150px;
  background: #e9ecef;
  position: relative;
}
.msg-location-iframe {
  width: 100%;
  height: 100%;
  border: none;
  pointer-events: none;
}
.msg-location-map:hover .msg-location-iframe {
  pointer-events: auto;
}
.msg-location-info {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
}
.msg-location-icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}
.msg-location-details {
  flex: 1;
  min-width: 0;
}
.msg-location-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 2px;
}
.msg-location-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  word-break: break-word;
}
.msg-location-coords {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 3px;
  font-family: monospace;
}
.msg-location-open {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: #e7f3ff;
  border: 1px solid #c6dff7;
  border-radius: 16px;
  color: var(--primary);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.15s;
  align-self: center;
}
.msg-location-open:hover {
  background: #d6eaff;
  border-color: var(--primary);
}

/* ===== Lightbox ===== */
.lightbox {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000; cursor: pointer;
}
.lightbox img {
  max-width: 90vw; max-height: 90vh;
  object-fit: contain; border-radius: 4px;
  cursor: default;
}
.lightbox-close {
  position: fixed; top: 16px; right: 16px;
  background: rgba(255,255,255,0.2); border: none;
  color: #fff; font-size: 24px; width: 40px; height: 40px;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-close:hover { background: rgba(255,255,255,0.4); }

/* ===== Phone Result Modal ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
}
.modal-content {
  background: var(--surface); border-radius: 12px;
  padding: 16px; width: 380px; max-height: 60vh;
  overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; font-size: 14px; margin-bottom: 12px;
}
/* ===== Phone Result Panel (inline, below thread list) ===== */
.phone-result-panel {
  border-top: 1px solid var(--border);
  background: linear-gradient(135deg, #f8faff 0%, #fff 100%);
  max-height: 380px;
  overflow-y: auto;
}
.phone-panel-inner {
  padding: 12px 14px;
}
.phone-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; font-size: 13px; margin-bottom: 10px;
  color: var(--primary);
}
.phone-panel-empty {
  text-align: center; padding: 20px 0;
  color: var(--text-light); font-size: 13px;
}
.phone-panel-profile {
  text-align: center; padding: 8px 0 12px;
}
.phone-panel-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  object-fit: cover; border: 3px solid var(--primary);
  margin-bottom: 8px;
}
.phone-panel-avatar-fallback {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--border); display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 28px; margin-bottom: 8px;
}
.phone-panel-name {
  font-weight: 700; font-size: 16px; color: var(--text-main);
}
.phone-panel-meta {
  display: flex; gap: 8px; justify-content: center;
  align-items: center; margin-top: 4px; font-size: 12px;
}
.phone-panel-id {
  font-size: 10px; color: var(--text-light); margin-top: 2px;
}
.phone-badge {
  padding: 2px 8px; border-radius: 10px; font-size: 11px;
}
.phone-badge-friend { background: #e8f5e9; color: #2e7d32; }
.phone-badge-stranger { background: #f5f5f5; color: #9e9e9e; }

.phone-panel-actions {
  display: flex; gap: 6px; margin-top: 12px; justify-content: center;
}
.phone-action-btn {
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: #fff;
  cursor: pointer; font-size: 11px; font-weight: 500;
  transition: all 0.15s; min-width: 68px;
}
.phone-action-btn:hover { background: #f0f7ff; border-color: var(--primary); }
.phone-action-icon { font-size: 20px; }
.phone-action-save:hover { border-color: #43a047; background: #e8f5e9; }
.phone-action-msg:hover { border-color: #1976d2; background: #e3f2fd; }
.phone-action-friend:hover { border-color: #f57c00; background: #fff3e0; }
.phone-action-done {
  background: #e8f5e9 !important; border-color: #43a047 !important;
  color: #2e7d32; pointer-events: none;
}

.phone-panel-msg-area {
  margin-top: 10px;
}
.phone-panel-msg-input {
  width: 100%; padding: 8px 10px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 8px;
  resize: none; font-family: inherit; box-sizing: border-box;
}
.phone-panel-msg-input:focus { outline: none; border-color: var(--primary); }
.phone-panel-send-btn { margin-top: 6px; width: 100%; }

/* Thread phone number display */
.thread-phone {
  font-size: 10px; color: var(--text-light);
  font-weight: 400; margin-left: 4px;
  opacity: 0.7;
}


/* ===== Product Search Tab ===== */
.product-search-panel { padding: 12px; height: 100%; display: flex; flex-direction: column; }
.ps-header { font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.ps-search-row { display: flex; gap: 6px; margin-bottom: 8px; }
.ps-search-row input {
  flex: 1; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; outline: none; font-size: 13px; background: #f8f9fa;
}
.ps-search-row input:focus { border-color: var(--primary); background: #fff; }
.ps-filters { display: flex; gap: 6px; margin-bottom: 8px; }
.ps-filter-input {
  flex: 1; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 11px; background: #f8f9fa; outline: none;
}
.ps-filter-input:focus { border-color: var(--primary); }
.ps-results { flex: 1; overflow-y: auto; }
.ps-count { font-size: 11px; color: var(--text-light); margin-bottom: 6px; font-weight: 500; }
.ps-product-card {
  display: flex; gap: 8px; padding: 8px;
  border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 6px; cursor: pointer;
  transition: all 0.15s;
}
.ps-product-card:hover { border-color: var(--primary); background: #f8fbff; }
.ps-product-img {
  width: 56px; height: 56px; border-radius: 6px;
  object-fit: cover; flex-shrink: 0; cursor: pointer;
}
.ps-product-info { flex: 1; min-width: 0; }
.ps-product-name { font-weight: 600; font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-product-code { font-size: 11px; color: var(--text-light); }
.ps-product-price { font-size: 12px; font-weight: 600; color: var(--red); }
.ps-product-stock { font-size: 11px; }
.stock-ok { color: var(--green); }
.stock-low { color: var(--orange); }
.stock-out { color: var(--red); }
.ps-product-actions { display: flex; flex-direction: column; gap: 4px; justify-content: center; }

/* ===== Badge Styles ===== */
.badge-model { font-size: 10px; padding: 2px 6px; border-radius: 4px; margin-left: 6px; }
.badge-premium { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; }
.badge-mini { background: #e0e7ff; color: #4338ca; }

.btn-sm {
  font-size: 11px; padding: 4px 8px;
  border-radius: 6px; cursor: pointer;
  white-space: nowrap;
}

/* AI Extract checkboxes */
.ai-extract-item {
  display: flex; gap: 6px; align-items: flex-start;
  padding: 4px 0; font-size: 12px; cursor: pointer;
}
.ai-extract-item input[type=checkbox] { margin-top: 2px; }
.ai-extract-item b { color: var(--text-muted); }

.cp-product {
  display: flex; gap: 8px; padding: 6px;
  border: 1px solid var(--border); border-radius: 6px;
  margin-bottom: 4px; cursor: pointer;
  transition: background 0.15s;
}
.cp-product:hover { background: #f0f7ff; }
.cp-product-img {
  width: 36px; height: 36px; border-radius: 4px;
  object-fit: cover; flex-shrink: 0;
}
.cp-product-info { flex: 1; }

/* ===== Thread Status Indicators ===== */
.thread-item.unseen {
  background: #fff8e1;
  border-left: 3px solid #ff9800;
}
.thread-item.unseen .name { color: #e65100; }
.thread-item.unreplied {
  background: #fce4ec;
  border-left: 3px solid #e91e63;
}
.thread-item.pinned {
  background: linear-gradient(135deg, #f3e5f5 0%, #ede7f6 100%);
}
.thread-item.pinned::before {
  content: '📌';
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 10px;
}
.thread-item.kept {
  background: linear-gradient(135deg, #e3f2fd 0%, #e8eaf6 100%);
  border-left: 3px solid #42a5f5;
}
.thread-item.kept::before {
  content: '\2693';
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 10px;
}
.unseen-badge {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ff9800; display: inline-block;
  margin-right: 4px; flex-shrink: 0;
  animation: pulse 1.5s infinite;
}
.thread-status-label {
  font-size: 10px; font-weight: 600;
  padding: 1px 5px; border-radius: 6px;
  display: inline-block;
}
.label-unseen { background: #fff3e0; color: #e65100; }
.label-unreplied { background: #fce4ec; color: #c62828; }
.label-replied { background: #e8f5e9; color: #2e7d32; }
.label-done { background: #e8f5e9; color: #2e7d32; }
.label-pinned { background: #f3e5f5; color: #7b1fa2; }

/* ===== Active Thread Highlight (MUST be after all state classes to win cascade) ===== */
.thread-item.active {
  background: linear-gradient(90deg, #dbeafe 0%, #eff6ff 100%);
  border-left: 4px solid #2563eb;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.15), 0 1px 3px rgba(37, 99, 235, 0.08);
}
.thread-item.active .name { color: #1e40af; }
.thread-item.active:hover { background: linear-gradient(90deg, #c7d8f5 0%, #dbeafe 100%); }

/* Unreplied warning badge */
.unreplied-warn-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  font-size: 12px;
  animation: unrepliedPulse 2s ease-in-out infinite;
  vertical-align: middle;
}
@keyframes unrepliedPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

/* Keep button */
.btn-keep {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid #90caf9;
  border-radius: 6px;
  background: #e3f2fd;
  color: #1565c0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}
.btn-keep:hover { background: #bbdefb; }
.btn-keep.active {
  background: #1565c0;
  color: #fff;
  border-color: #1565c0;
}
.btn-keep.active:hover { background: #0d47a1; }

/* Unread button */
.btn-unread {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid #ffcc80;
  border-radius: 6px;
  background: #fff3e0;
  color: #e65100;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
}
.btn-unread:hover { background: #ffe0b2; }
.btn-unread:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Pending Order toggle */
.pending-order-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 1px solid #ffcc80;
  border-radius: 6px;
  background: #fff8e1;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
  user-select: none;
}
.pending-order-toggle:hover { background: #ffecb3; }
.pending-order-toggle input[type="checkbox"] {
  margin: 0;
  accent-color: #e65100;
}
.pending-order-label {
  color: #e65100;
  font-weight: 500;
  font-size: 11px;
}

/* ===== Context Menu ===== */
.context-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 8000;
  min-width: 180px;
  padding: 4px 0;
}
.ctx-item {
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}
.ctx-item:hover { background: #f0f7ff; }
.ctx-separator { border-top: 1px solid var(--border); margin-top: 2px; padding-top: 10px; }

/* ===== Summary Modal ===== */
.summary-modal { width: 520px; max-width: 90vw; }
.summary-content { padding: 8px 0; }
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.summary-card {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.summary-card .val {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}
.summary-card .lbl {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.summary-section {
  margin-bottom: 12px;
}
.summary-section-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.summary-thread-item {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #fff8e1;
  margin-bottom: 3px;
}
.summary-thread-item.negative {
  background: #ffebee;
}

/* ===== Topbar Actions ===== */
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ===== GPT Chat in Copilot ===== */
.gpt-chat-section {
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100%; min-height: 200px;
  margin-top: 8px;
}
.gpt-chat-header {
  font-weight: 700; font-size: 13px;
  padding: 8px 12px;
  background: linear-gradient(135deg, #e8f5e9, #e3f2fd);
  color: #1565c0; border-radius: 8px 8px 0 0;
  display: flex; justify-content: space-between; align-items: center;
}
.gpt-chat-messages {
  flex: 1; overflow-y: auto;
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 6px;
  max-height: 350px; min-height: 120px;
  background: #fafbfc;
}
.gpt-chat-welcome {
  text-align: center; padding: 24px 12px;
  color: var(--text-light); font-size: 12px;
}
.gpt-msg {
  display: flex; max-width: 92%;
}
.gpt-msg-user {
  align-self: flex-end; flex-direction: row-reverse;
}
.gpt-msg-assistant { align-self: flex-start; }
.gpt-msg-system { align-self: center; }
.gpt-msg-content {
  padding: 8px 12px; border-radius: 12px;
  font-size: 12px; line-height: 1.5;
  word-break: break-word;
}
.gpt-msg-user .gpt-msg-content {
  background: linear-gradient(135deg, #1976d2, #1565c0);
  color: #fff; border-bottom-right-radius: 4px;
}
.gpt-msg-assistant .gpt-msg-content {
  background: #fff; border: 1px solid var(--border);
  color: var(--text-main); border-bottom-left-radius: 4px;
}
.gpt-msg-content ul {
  margin: 4px 0; padding-left: 16px;
}
.gpt-msg-content li {
  margin: 2px 0;
}
.gpt-msg-content strong {
  color: #1565c0;
}

/* Typing animation */
.gpt-typing {
  display: flex; gap: 4px; padding: 4px 0;
}
.gpt-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #90a4ae;
  animation: gptBounce 1.2s infinite ease-in-out;
}
.gpt-typing span:nth-child(2) { animation-delay: 0.2s; }
.gpt-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes gptBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Tool usage badge */
.gpt-tool-badge {
  align-self: center;
  background: #fff3e0; border: 1px solid #ffe0b2;
  color: #e65100; font-size: 10px;
  padding: 3px 10px; border-radius: 12px;
  margin: 2px 0;
}
.gpt-tool-badge em {
  color: #bf360c; font-style: normal;
}

/* Input area */
.gpt-chat-input-area {
  display: flex; gap: 6px; padding: 8px 10px;
  border-top: 1px solid var(--border);
  background: #fff;
}
.gpt-chat-input {
  flex: 1; padding: 8px 10px; font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 8px; resize: none;
  font-family: inherit; line-height: 1.4;
}
.gpt-chat-input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.1);
}
.gpt-chat-send-btn {
  padding: 8px 14px; border-radius: 8px;
  border: none; background: var(--primary);
  color: #fff; cursor: pointer; font-size: 14px;
  transition: all 0.15s; align-self: flex-end;
}
.gpt-chat-send-btn:hover { background: #1565c0; }
.gpt-chat-send-btn:disabled {
  opacity: 0.5; cursor: not-allowed;
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 260px 1fr 300px; }
  :root { --sidebar-w: 260px; --right-w: 300px; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .panel-left, .panel-right { display: none; }
  .settings-layout { flex-direction: column; }
  .settings-sidebar { flex-direction: row; overflow-x: auto; width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--border); }
  .settings-tab { white-space: nowrap; font-size: 12px; padding: 10px 14px; border-bottom: 2px solid transparent; }
  .settings-tab.active { border-bottom-color: var(--primary); background: transparent; }
}

/* ===== Settings Layout ===== */
.settings-layout {
  display: flex;
  height: calc(100vh - var(--topbar-h));
  background: var(--bg);
}
.settings-sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px 0;
  flex-shrink: 0;
  overflow-y: auto;
}
.settings-tab {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 18px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}
.settings-tab:hover {
  background: #f0f7ff;
  color: var(--text);
}
.settings-tab.active {
  background: linear-gradient(90deg, #e3f2fd, transparent);
  color: var(--primary);
  font-weight: 600;
  border-left: 3px solid var(--primary);
}
.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.settings-panel {
  display: none;
  padding: 28px 32px;
  max-width: 800px;
}
.settings-panel.active {
  display: block;
  animation: fadeInPanel 0.2s ease;
}
@keyframes fadeInPanel {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.settings-panel h2 {
  margin: 0 0 4px;
  font-size: 20px;
  color: var(--text);
}
.settings-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ===== Form Components ===== */
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  font-size: 13px;
  transition: border-color 0.2s;
  font-family: var(--font);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,132,255,0.08);
}
.form-group textarea { resize: vertical; }
.form-hint {
  display: block;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* Switch toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #ccc;
  border-radius: 24px;
  transition: 0.3s;
}
.switch-slider::before {
  content: '';
  position: absolute;
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .switch-slider {
  background: var(--primary);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}
.switch-sm { width: 36px; height: 20px; }
.switch-sm .switch-slider::before {
  height: 14px; width: 14px;
  left: 3px; bottom: 3px;
}
.switch-sm input:checked + .switch-slider::before {
  transform: translateX(16px);
}

/* Save status */
.save-status {
  font-size: 12px;
  margin-top: 8px;
  min-height: 18px;
  transition: all 0.2s;
}
.save-status.success { color: var(--green); }
.save-status.error { color: var(--red); }

/* Queue status */
.queue-status {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
}
.queue-item {
  padding: 4px 0;
  font-size: 12px;
}

/* Upload area */
.upload-area {
  background: linear-gradient(135deg, #f8faff 0%, #f0f7ff 100%);
  border: 2px dashed #c6dff7;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  transition: border-color 0.2s;
}
.upload-area:hover { border-color: var(--primary); }
.upload-area input[type="file"] {
  margin-bottom: 12px;
  font-size: 13px;
}

/* File list */
.file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.file-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all 0.15s;
}
.file-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0,132,255,0.08);
}
.file-icon {
  font-size: 28px;
  width: 40px;
  text-align: center;
  flex-shrink: 0;
}
.file-info { flex: 1; min-width: 0; }
.file-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-meta {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}
.file-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.file-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Plugin list */
.plugin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.plugin-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all 0.15s;
}
.plugin-item:hover {
  border-color: #ddd;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.plugin-info { flex: 1; }
.plugin-name {
  font-weight: 600;
  font-size: 14px;
}
.plugin-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* User list */
.user-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all 0.15s;
}
.user-item:hover { border-color: #ddd; }
.user-item.user-inactive { opacity: 0.5; }
.user-info { flex: 1; }
.user-name { font-weight: 600; font-size: 13px; }
.user-meta {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}
.user-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.user-actions select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: #fff;
}
.user-add-area {
  background: linear-gradient(135deg, #f0f7ff 0%, #f8faff 100%);
  border: 1px solid #c6dff7;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.user-add-area h3 {
  margin: 0 0 14px;
  font-size: 15px;
  color: var(--primary);
}

/* ===== Notices Layout ===== */
.notices-layout {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 20px;
}
.notices-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.notices-header h2 {
  margin: 0;
  font-size: 22px;
}

/* Notice form */
.notice-form {
  background: linear-gradient(135deg, #f0f7ff 0%, #f8faff 100%);
  border: 1px solid #c6dff7;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  animation: fadeInPanel 0.2s ease;
}

/* Notice cards */
.notice-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.notice-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  transition: all 0.15s;
}
.notice-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  border-color: #ddd;
}
.notice-card.notice-pinned {
  border-left: 4px solid var(--purple);
  background: linear-gradient(135deg, #faf5ff 0%, #fff 100%);
}
.notice-card-header {
  padding: 14px 18px 8px;
}
.notice-card-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}
.notice-card-meta {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}
.notice-card-body {
  padding: 0 18px 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}
.notice-card-actions {
  padding: 8px 18px;
  border-top: 1px solid #f5f5f5;
  display: flex;
  gap: 8px;
}
.notice-card-actions .btn-ghost-sm {
  font-size: 12px;
  color: var(--text-muted);
}
.notice-card-actions .btn-ghost-sm:hover {
  background: #f0f7ff;
  color: var(--primary);
}

/* ===== GPT Mode Toggle (Copilot) ===== */
.gpt-mode-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #f8f9fa;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 8px;
}
.gpt-mode-label {
  font-weight: 500;
  color: var(--text-muted);
}
.gpt-mode-internal { color: #2e7d32; }
.gpt-mode-extended { color: #1565c0; }

/* ===== Account Badge on Threads ===== */
.account-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 8px;
  background: #e8eaf6;
  color: #3949ab;
  font-weight: 600;
  white-space: nowrap;
}

/* ===== Assigned Badge ===== */
.assigned-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  background: #ede7f6;
  color: #7b1fa2;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.assigned-to-me {
  background: #e8f5e9;
  color: #2e7d32;
}

/* ===== Thread Replied-by Info ===== */
.thread-replied-by {
  font-size: 10px;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ===== Composer Row Layout ===== */
.composer-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

/* ===== Reply Bar ===== */
.reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f0f7ff;
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  margin-bottom: 8px;
  animation: slideDown 0.2s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.reply-bar-content {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.reply-bar-icon { font-size: 14px; flex-shrink: 0; }
.reply-bar-text {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-bar-close {
  background: transparent;
  border: none;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-light);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.reply-bar-close:hover { background: #e0e0e0; }

/* ===== Schedule UI ===== */
.schedule-checkbox {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s;
}
.schedule-checkbox:hover { background: #f0f7ff; }
.schedule-checkbox input { display: none; }
.schedule-checkbox input:checked + span { color: var(--primary); }
.schedule-checkbox span { font-size: 16px; opacity: 0.5; transition: opacity 0.2s; }
.schedule-checkbox input:checked + span { opacity: 1; }

.schedule-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  margin-top: 4px;
  animation: slideDown 0.2s ease;
}
.schedule-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}
.schedule-datetime {
  padding: 6px 10px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  font-size: 13px;
  background: #f0f7ff;
  outline: none;
}
.schedule-tz {
  font-size: 11px;
  color: var(--text-light);
}

/* ===== Blocked Banner & Thread ===== */
.blocked-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: #fff0f0;
  border: 1px solid #ffd0d0;
  border-radius: 8px;
  color: #c62828;
  font-size: 12px;
  font-weight: 500;
  margin-top: 6px;
  animation: slideDown 0.2s ease;
}
.thread-item.blocked {
  opacity: 0.5;
  background: #fafafa;
}
.thread-item.blocked .name {
  text-decoration: line-through;
  color: var(--text-light);
}
.badge-blocked {
  background: #ffebee;
  color: #c62828;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

/* ===== Message Reply Indicator ===== */
.msg-reply-indicator {
  background: rgba(0,132,255,0.08);
  border-left: 2px solid var(--primary);
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--text-muted);
  max-height: 36px;
  overflow: hidden;
  cursor: pointer;
}
.msg-reply-indicator:hover { background: rgba(0,132,255,0.12); }

/* ===== Message Context Menu Trigger ===== */
.msg:hover .msg-actions-hover {
  opacity: 1;
}
.msg-actions-hover {
  position: absolute;
  top: 4px;
  right: 4px;
  opacity: 0;
  transition: opacity 0.15s;
  display: flex;
  gap: 2px;
}
.msg.in .msg-actions-hover {
  right: auto;
  left: 4px;
}
.msg-action-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: all 0.15s;
}
.msg-action-btn:hover { background: #f0f7ff; border-color: var(--primary); }

/* ===== File Display (received files) ===== */
.msg-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 300px;
  margin-top: 4px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: var(--text);
}
.msg-file-card:hover { border-color: var(--primary); background: #f0f7ff; }
.msg-file-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.msg-file-info {
  flex: 1;
  min-width: 0;
}
.msg-file-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-file-meta {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}
.msg-file-download {
  font-size: 18px;
  color: var(--primary);
  flex-shrink: 0;
}

/* ===== Video Player ===== */
.msg-video-player {
  max-width: 300px;
  border-radius: 10px;
  overflow: hidden;
  margin-top: 4px;
}
.msg-video-player video {
  width: 100%;
  max-height: 240px;
  border-radius: 10px;
}

/* ===== Settings: AutoPilot ===== */
.autopilot-rule-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  transition: all 0.15s;
}
.autopilot-rule-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.autopilot-rule-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.autopilot-trigger {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.autopilot-meta {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}
.autopilot-replies-preview {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 8px;
  margin-top: 8px;
  font-size: 12px;
  max-height: 120px;
  overflow-y: auto;
}
.autopilot-reply-item {
  padding: 4px 0;
  border-bottom: 1px dashed #eee;
}
.autopilot-reply-item:last-child { border-bottom: none; }
.autopilot-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

/* ===== Composer Row ===== */
.composer-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  width: 100%;
}
.composer-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

/* ===== Reply Bar ===== */
.reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #e3f2fd;
  border-left: 3px solid var(--primary);
  padding: 6px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 12px;
  animation: slideDown 0.2s ease;
}
.reply-bar-content {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  flex: 1;
}
.reply-bar-icon { font-size: 14px; }
.reply-bar-text {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-bar-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-light);
  padding: 2px 6px;
  border-radius: 50%;
}
.reply-bar-close:hover {
  background: rgba(0,0,0,0.1);
  color: var(--red);
}

/* ===== Schedule Picker ===== */
.schedule-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 16px;
  user-select: none;
}
.schedule-checkbox input[type="checkbox"] {
  display: none;
}
.schedule-checkbox input:checked + span {
  background: var(--primary);
  color: #fff;
  border-radius: 4px;
  padding: 2px 4px;
}
.schedule-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 12px;
  animation: slideDown 0.2s ease;
}
.schedule-hint { color: var(--primary); font-weight: 600; }
.schedule-datetime {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.schedule-tz { color: var(--text-light); font-size: 11px; }

/* ===== Blocked Banner ===== */
.blocked-banner {
  background: #ffebee;
  border: 1px solid #ffcdd2;
  color: #c62828;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  animation: slideDown 0.2s ease;
}

/* ===== Message Context Menu ===== */
.msg-context-menu {
  display: none;
  position: fixed;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 1000;
  min-width: 180px;
  padding: 6px 0;
  animation: fadeIn 0.15s ease;
}
.msg-context-menu .ctx-item {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  color: var(--text);
}
.msg-context-menu .ctx-item:hover {
  background: var(--hover);
}

/* ===== Forward Modal ===== */
.forward-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1001;
  justify-content: center;
  align-items: center;
}
.forward-modal.visible {
  display: flex;
}
.forward-modal-content {
  background: #fff;
  border-radius: 12px;
  width: 420px;
  max-height: 500px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  animation: fadeIn 0.2s ease;
}
.forward-modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}
.forward-search {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}
.forward-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.forward-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  max-height: 300px;
}
.forward-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.forward-item:hover { background: var(--hover); }
.forward-item.selected { background: #e3f2fd; }
.forward-item-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.forward-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ===== Message Hover Actions ===== */
.msg {
  position: relative;
}
.msg-actions-hover {
  display: none;
  position: absolute;
  top: 4px;
  gap: 2px;
  z-index: 5;
}
.msg.in .msg-actions-hover { right: -24px; }
.msg.out .msg-actions-hover { left: -24px; }
.msg:hover .msg-actions-hover {
  display: flex;
}
.msg-action-btn {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  transition: background 0.15s;
}
.msg-action-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* ===== Reply Indicator ===== */
.msg-reply-indicator {
  font-size: 11px;
  color: var(--primary);
  margin-bottom: 4px;
  padding: 2px 8px;
  background: rgba(63,81,181,0.06);
  border-left: 2px solid var(--primary);
  border-radius: 4px;
}

/* ===== File Card ===== */
.msg-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f5f7fa;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 200px;
  max-width: 320px;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}
.msg-file-card:hover { background: #e8edf2; }
.msg-file-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.msg-file-info {
  flex: 1;
  overflow: hidden;
}
.msg-file-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.msg-file-meta {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
}
.msg-file-download {
  font-size: 18px;
  flex-shrink: 0;
  color: var(--primary);
}
.msg-video-player video {
  max-width: 320px;
  border-radius: 8px;
}

/* ===== Blocked Thread Styles ===== */
.thread-item.blocked {
  opacity: 0.5;
}
.thread-item.blocked .thread-name {
  text-decoration: line-through;
}
.thread-blocked-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #ffebee;
  color: #c62828;
  font-weight: 600;
  margin-left: 4px;
}
.badge-blocked {
  background: #ffebee !important;
  color: #c62828 !important;
  font-size: 10px;
  font-weight: 600;
}

/* ===== Animations ===== */
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== Context Menu (Right-click) ===== */
.context-menu {
  position: fixed;
  z-index: 9999;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  padding: 6px 0;
  animation: ctxFadeIn 0.12s ease-out;
}
@keyframes ctxFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
  color: var(--text);
}
.ctx-item:hover {
  background: var(--primary-light, #e8eaf6);
  color: var(--primary);
}
.ctx-item:first-child { border-radius: 10px 10px 0 0; }
.ctx-item:last-child { border-radius: 0 0 10px 10px; }
.ctx-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.ctx-item.danger {
  color: #d32f2f;
}
.ctx-item.danger:hover {
  background: #ffebee;
  color: #c62828;
}

/* ===== Emoji Reaction Picker ===== */
.reaction-picker {
  position: fixed;
  z-index: 10000;
  display: flex;
  gap: 2px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 6px 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.15);
  animation: ctxFadeIn 0.15s ease-out;
}
.reaction-emoji {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.reaction-emoji:hover {
  transform: scale(1.3);
  background: #f0f0f0;
}

/* ===== Scheduled Messages Panel ===== */
.scheduled-panel {
  background: #fffde7;
  border: 1px solid #fff9c4;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}
.scheduled-panel h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #f57f17;
  font-weight: 600;
}
.scheduled-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px;
  background: #fff;
  border: 1px solid #fff9c4;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}
.scheduled-item:last-child { margin-bottom: 0; }
.scheduled-item-content {
  flex: 1;
  overflow: hidden;
}
.scheduled-item-text {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scheduled-item-time {
  color: var(--text-light);
  font-size: 11px;
  margin-top: 2px;
}
.scheduled-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.scheduled-item-actions button {
  padding: 3px 8px;
  font-size: 11px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}
.scheduled-item-actions button:hover {
  background: #f5f5f5;
}
.scheduled-item-actions .btn-cancel {
  color: #d32f2f;
  border-color: #ffcdd2;
}
.scheduled-item-actions .btn-cancel:hover {
  background: #ffebee;
}

/* ===== Modal Overlay ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s;
}
.modal-content {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.2);
  width: 90%;
  max-width: 500px;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}

/* ===== Reply Bar ===== */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(63,81,181,0.06);
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  margin: 0 12px 4px;
  font-size: 12px;
  color: var(--text);
  animation: slideDown 0.15s ease-out;
}
.reply-bar-text {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.reply-bar-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-light);
  padding: 2px 4px;
  border-radius: 4px;
}
.reply-bar-close:hover {
  background: rgba(0,0,0,0.08);
}

/* ===== Context Menus ===== */
.context-menu {
  position: fixed;
  z-index: 10000;
  min-width: 180px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  padding: 6px 0;
  font-size: 13px;
  border: 1px solid rgba(0,0,0,0.06);
  overflow: hidden;
  animation: ctxFadeIn 0.12s ease;
}
@keyframes ctxFadeIn {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.ctx-item {
  padding: 9px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
  color: #333;
  font-weight: 500;
}
.ctx-item:hover {
  background: #f0f4ff;
  color: var(--primary);
}
.ctx-item.danger {
  color: #e53935;
}
.ctx-item.danger:hover {
  background: #ffeaea;
  color: #c62828;
}
.ctx-divider {
  height: 1px;
  background: #eee;
  margin: 4px 8px;
}

/* ===== Reaction Picker ===== */
.reaction-picker {
  position: fixed;
  z-index: 10001;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 6px 10px;
  display: flex;
  gap: 4px;
  align-items: center;
  animation: ctxFadeIn 0.12s ease;
}
.reaction-emoji {
  font-size: 22px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  border: none;
  background: transparent;
  transition: transform 0.15s, background 0.15s;
  line-height: 1;
}
.reaction-emoji:hover {
  transform: scale(1.35);
  background: rgba(0,0,0,0.05);
}

/* ===== Scheduled Messages Panel ===== */
.scheduled-panel {
  background: linear-gradient(135deg, #fff8e1, #fff3cd);
  border: 1px solid #ffe082;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 16px;
}
.scheduled-panel h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: #e65100;
}
.scheduled-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.scheduled-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.85);
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid #ffe082;
  gap: 8px;
}
.scheduled-item-content {
  flex: 1;
  min-width: 0;
}
.scheduled-item-text {
  font-size: 13px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}
.scheduled-item-time {
  font-size: 11px;
  color: #e65100;
  font-weight: 500;
}
.scheduled-item-actions .btn-cancel {
  background: transparent;
  border: 1px solid #ef5350;
  color: #ef5350;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.scheduled-item-actions .btn-cancel:hover {
  background: #ef5350;
  color: #fff;
}

/* ===== File Message Cards ===== */
.msg-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #f0f4ff;
  border: 1px solid #d6e0f5;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 200px;
  max-width: 320px;
  transition: background 0.2s, box-shadow 0.2s;
}
.msg-file-card:hover {
  background: #e3ebff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.msg-file-card[href] {
  cursor: pointer;
}
.msg-file-icon {
  font-size: 28px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}
.msg-file-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.msg-file-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1a237e;
}
.msg-file-meta {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
}
.msg-file-download {
  font-size: 18px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.msg-file-card:hover .msg-file-download {
  opacity: 1;
}

/* ===== Video Player in Messages ===== */
.msg-video-player {
  max-width: 340px;
}
.msg-video-player video {
  width: 100%;
  max-width: 320px;
  border-radius: 8px;
  background: #000;
}

/* ===== Audio Player in Messages ===== */
.msg-audio-player {
  min-width: 220px;
  max-width: 300px;
}
.msg-audio-player .msg-audio-el {
  width: 100%;
  height: 36px;
  border-radius: 18px;
}

/* ===== Toggle Switch ===== */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
  vertical-align: middle;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 26px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
input:checked + .slider {
  background: linear-gradient(135deg, #4CAF50, #45a049);
}
input:checked + .slider:before {
  transform: translateX(22px);
}
input:focus + .slider {
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

/* ===== AutoPilot Rule Cards ===== */
.autopilot-rule-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  transition: box-shadow 0.2s;
}
.autopilot-rule-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.autopilot-rule-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}
.autopilot-trigger {
  font-weight: 600;
  font-size: 14px;
  color: #1a237e;
}
.autopilot-meta {
  font-size: 12px;
  color: #666;
  margin-top: 2px;
}
.autopilot-replies-preview {
  margin: 8px 0;
  padding: 8px;
  background: #f5f7fa;
  border-radius: 6px;
  font-size: 12px;
  max-height: 100px;
  overflow-y: auto;
}
.autopilot-replies-list {
  margin: 8px 0;
  padding: 8px;
  background: #f5f7fa;
  border-radius: 6px;
  font-size: 12px;
  max-height: 400px;
  overflow-y: auto;
}
.autopilot-reply-item {
  padding: 3px 0;
  border-bottom: 1px solid #eee;
  color: #555;
}
.autopilot-reply-item:last-child {
  border-bottom: none;
}
.autopilot-reply-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid #eee;
  transition: opacity 0.2s, background 0.2s;
}
.autopilot-reply-row:last-child { border-bottom: none; }
.autopilot-reply-row:hover { background: rgba(0,0,0,0.02); }
.autopilot-reply-row.reply-disabled {
  opacity: 0.4;
  text-decoration: line-through;
}
.autopilot-reply-toggle {
  flex-shrink: 0;
  cursor: pointer;
  margin-top: 2px;
}
.autopilot-reply-toggle input { cursor: pointer; }
.autopilot-reply-text {
  flex: 1;
  color: #555;
  line-height: 1.4;
  word-break: break-word;
}
.autopilot-reply-edit {
  width: 100%;
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font);
  resize: vertical;
}
.autopilot-reply-edit-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  justify-content: flex-end;
}
.autopilot-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ===== Toast Notification ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #323232;
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  z-index: 99999;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Reaction Hover Bar on Messages ===== */
.msg-reaction-hover {
  display: none;
  position: absolute;
  top: -14px;
  gap: 2px;
  z-index: 10;
  background: #fff;
  border-radius: 20px;
  padding: 2px 4px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  border: 1px solid rgba(0,0,0,0.06);
}
.msg.out .msg-reaction-hover { left: 8px; }
.msg.in .msg-reaction-hover { right: 8px; }
.msg:hover .msg-reaction-hover {
  display: flex;
}
.reaction-hover-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
  padding: 0;
  line-height: 1;
}
.reaction-hover-btn:hover {
  transform: scale(1.35);
  background: #f0f0f0;
}

/* ===== Reply Preview Bubble (quoted message in reply) ===== */
.msg-reply-preview {
  background: rgba(0,0,0,0.04);
  border-left: 3px solid #2563eb;
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.15s;
  max-width: 100%;
  overflow: hidden;
}
.msg-reply-preview:hover {
  background: rgba(37, 99, 235, 0.08);
}
.msg.out .msg-reply-preview {
  border-left-color: #059669;
  background: rgba(5, 150, 105, 0.06);
}
.msg.out .msg-reply-preview:hover {
  background: rgba(5, 150, 105, 0.12);
}
.reply-preview-header {
  font-size: 11px;
  font-weight: 600;
  color: #2563eb;
  margin-bottom: 1px;
}
.msg.out .reply-preview-header {
  color: #059669;
}
.reply-preview-text {
  font-size: 12px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 350px;
}

/* ===== Message Highlight Flash (scroll-to-quoted) ===== */
.msg-highlight-flash {
  animation: msgFlash 2s ease;
}
@keyframes msgFlash {
  0% { background-color: rgba(37, 99, 235, 0.25); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3); }
  50% { background-color: rgba(37, 99, 235, 0.12); box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15); }
  100% { background-color: transparent; box-shadow: none; }
}

/* ===== Reaction Pills (emoji badges on messages) ===== */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
  margin-bottom: 2px;
}
.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  font-size: 14px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  cursor: default;
  transition: background 0.15s, transform 0.15s;
  line-height: 1.4;
}
.reaction-pill:hover {
  background: #e5e7eb;
  transform: scale(1.1);
}
.msg.out .reaction-pill {
  background: rgba(5, 150, 105, 0.08);
  border-color: rgba(5, 150, 105, 0.15);
}

/* ===== Pinned Messages in Customer Tab ===== */
.pf-pinned-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pf-pinned-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: #fef9e7;
  border: 1px solid #fce4a4;
  border-radius: 8px;
  border-left: 3px solid #f39c12;
  transition: background 0.15s;
}
.pf-pinned-item:hover {
  background: #fdf3d1;
}
.pf-pinned-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.pf-pinned-sender {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.pf-pinned-time {
  font-weight: 400;
  color: var(--text-light);
  margin-left: 4px;
}
.pf-pinned-text {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.pf-pinned-remove {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-light);
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: all 0.15s;
}
.pf-pinned-remove:hover {
  background: #ffebee;
  color: #c62828;
}

/* ===== Customer Tab Layout Fixes ===== */
.profile-form {
  gap: 8px;
}
.pf-group input,
.pf-group textarea,
.pf-group select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
.pf-group textarea {
  min-height: 36px;
}
.pf-row {
  gap: 6px;
}
.pf-tags {
  word-break: break-word;
}
.pf-tag {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pf-avatar-section {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 10px;
  margin-bottom: 4px;
}
.pf-avatar-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e3f2fd;
  font-size: 24px;
  flex-shrink: 0;
}
.pf-avatar-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pf-avatar-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.pf-zalo-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pf-actions {
  display: flex;
  gap: 6px;
}
.pf-actions .btn-primary,
.pf-actions .btn-outline {
  flex: 1;
  text-align: center;
}

/* ===== Link messages rendering fix ===== */
.msg-link-card {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: #f5f7fa;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  max-width: 320px;
  transition: background 0.15s, border-color 0.15s;
}
.msg-link-card:hover {
  background: #e8edf2;
  border-color: var(--primary);
}
.msg-link-thumb {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}
.msg-link-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.msg-link-title {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.msg-link-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.msg-link-url {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-link-card-static {
  cursor: default;
  background: linear-gradient(135deg, #f8f9fa 0%, #eef1f5 100%);
}
.msg-link-card-static:hover {
  background: linear-gradient(135deg, #f0f2f5 0%, #e6e9ed 100%);
  border-color: #c0c8d0;
}
.msg-link-card-static .msg-link-thumb {
  width: 72px;
  height: 72px;
  border-radius: 8px;
}
.msg-link-card-static .msg-link-desc {
  -webkit-line-clamp: 3;
}

/* ===== Sticker Picker ===== */
.sticker-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
  z-index: 100;
  max-height: 360px;
  display: flex;
  flex-direction: column;
  animation: stickerSlideUp 0.2s ease-out;
}
@keyframes stickerSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.sticker-picker-header {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  min-height: 36px;
}
.sticker-tabs {
  display: flex;
  flex: 1;
  gap: 0;
}
.sticker-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.sticker-tab:hover {
  color: var(--text);
  background: var(--bg);
}
.sticker-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.sticker-picker-close {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 0;
}
.sticker-picker-close:hover {
  background: var(--bg);
  color: var(--text);
}
.sticker-search-bar {
  display: flex;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.sticker-search-bar input {
  flex: 1;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  outline: none;
  font-size: 13px;
  background: var(--surface);
}
.sticker-search-bar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}
.sticker-grid {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 4px;
  align-content: start;
  min-height: 120px;
}
.sticker-item {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  width: 76px;
  height: 76px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  overflow: hidden;
}
.sticker-item:hover {
  background: var(--bg);
  transform: scale(1.12);
}
.sticker-item:active {
  transform: scale(0.95);
}
.sticker-item img {
  width: 60px;
  height: 60px;
  object-fit: contain;
}
.sticker-pack-bar {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  overflow-x: auto;
  scrollbar-width: thin;
}
.sticker-pack-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  padding: 2px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sticker-pack-btn:hover {
  background: var(--surface);
  border-color: var(--border);
}
.sticker-pack-btn.active {
  border-color: var(--primary);
  background: var(--surface);
}
.sticker-pack-btn img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 4px;
}
.sticker-pack-btn span {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}
.sticker-loading, .sticker-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 13px;
}
.sticker-loading::before {
  content: '';
  display: block;
  width: 24px;
  height: 24px;
  margin: 0 auto 8px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Modal Overlay ===== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Small button */
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 6px; }

/* ===== VNPost Orders Tab ===== */
.orders-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.order-stat-card {
  background: #f8f9fa;
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  border: 1px solid var(--border);
  transition: transform 0.15s;
}
.order-stat-card:hover { transform: translateY(-1px); }
.order-stat-number {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}
.order-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}
.stat-delivering .order-stat-number { color: #e67e22; }
.stat-delivered .order-stat-number { color: #27ae60; }
.stat-returned .order-stat-number { color: #e74c3c; }
.stat-failed .order-stat-number { color: #c0392b; }
.stat-total .order-stat-number { color: var(--primary); }
.stat-preparing .order-stat-number { color: #f39c12; }
.stat-preparing { background: #fef9e7; border-color: #fce4a4; }
.stat-cod .order-stat-number { color: #8e44ad; font-size: 14px; }

/* Orders lookup */
.orders-lookup-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.orders-lookup-row input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  outline: none;
  background: var(--bg);
}
.orders-lookup-row input:focus { border-color: var(--primary); background: #fff; }

/* Order list */
.orders-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Order card */
.order-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}
.order-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0,132,255,0.1);
}
.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 6px;
}
.order-card-code {
  font-weight: 700;
  font-size: 12px;
  color: var(--primary);
  letter-spacing: 0.3px;
}
.order-card-sale-code {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 1px;
}

/* Status badges */
.order-status-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-preparing {
  background: linear-gradient(135deg, #fef9e7, #fdf3d1);
  color: #e67e22;
  border: 1px solid #fce4a4;
}
.status-delivering {
  background: #fff3e0;
  color: #e65100;
}
.status-delivered {
  background: #e8f5e9;
  color: #2e7d32;
}
.status-returned {
  background: #fce4ec;
  color: #c62828;
}
.status-failed {
  background: #ffebee;
  color: #b71c1c;
  animation: pulse 2s infinite;
}
.status-cancelled {
  background: #f5f5f5;
  color: #757575;
}
.status-pending {
  background: #e3f2fd;
  color: #1565c0;
}
.status-other {
  background: #f5f5f5;
  color: #616161;
}

/* Order card body */
.order-card-receiver {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.order-card-address {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-light);
}
.order-card-cod {
  font-weight: 700;
  color: #8e44ad;
  font-size: 12px;
}
.order-card-cod.high-value {
  color: #c0392b;
  font-size: 13px;
}

/* Warning / Active / Preparing indicators */
.order-card.order-warning {
  border-left: 3px solid #e74c3c;
}
.order-card.order-active {
  border-left: 3px solid #e67e22;
}
.order-card.order-preparing {
  border-left: 3px dashed #f39c12;
  background: #fffdf5;
}
.order-card.order-preparing:hover {
  border-color: #f39c12;
  box-shadow: 0 2px 8px rgba(243,156,18,0.15);
}
.order-card.order-preparing .order-card-code {
  color: #e67e22;
}

/* Order detail modal */
.order-detail-modal {
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
}
.order-detail-content {
  padding: 16px;
}
.order-detail-section {
  margin-bottom: 16px;
}
.order-detail-section-title {
  font-weight: 700;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.order-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 4px 0;
  font-size: 13px;
  gap: 8px;
}
.order-detail-label {
  color: var(--text-muted);
  font-size: 12px;
  flex-shrink: 0;
  min-width: 100px;
}
.order-detail-value {
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}

/* Timeline */
.order-timeline {
  position: relative;
  padding-left: 24px;
}
.order-timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding-bottom: 12px;
  font-size: 12px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
}
.timeline-item:last-child .timeline-dot {
  background: var(--green);
}
.timeline-item:first-child .timeline-dot {
  background: var(--primary);
  width: 12px;
  height: 12px;
  left: -21px;
  top: 3px;
}
.timeline-status {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.timeline-time {
  color: var(--text-light);
  font-size: 11px;
}

/* Current status highlight */
.order-current-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: linear-gradient(135deg, #f0f7ff, #e8f0fe);
  border-radius: 10px;
  border: 1px solid #c6dff7;
  margin-bottom: 12px;
}
.order-current-status-icon {
  font-size: 28px;
}
.order-current-status-text {
  flex: 1;
}
.order-current-status-label {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.order-current-status-code {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Missed Call Message (Inline Chat) ===== */
.msg-call {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  min-width: 200px;
  max-width: 320px;
}
.msg-call.missed {
  background: linear-gradient(135deg, #fff5f5, #ffe8e8);
  border: 1px solid #ffcdd2;
  border-left: 3px solid #e53935;
}
.msg-call.answered {
  background: linear-gradient(135deg, #f1f8e9, #e8f5e9);
  border: 1px solid #c8e6c9;
  border-left: 3px solid #43a047;
}
.msg-call-icon {
  font-size: 22px;
  flex-shrink: 0;
}
.msg-call-info {
  flex: 1;
  min-width: 0;
}
.msg-call-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}
.msg-call.missed .msg-call-label { color: #c62828; }
.msg-call.answered .msg-call-label { color: #2e7d32; }
.msg-call-detail {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.btn-callback-inline {
  background: #fff;
  border: 1px solid #c8e6c9;
  color: #2e7d32;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-callback-inline:hover {
  background: #e8f5e9;
  border-color: #43a047;
}
.btn-callback-inline.done {
  background: #e8f5e9;
  color: #2e7d32;
  pointer-events: none;
}
.btn-callback-inline:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== Missed Calls Modal ===== */
.missed-calls-modal {
  max-width: 640px;
  max-height: 85vh;
}

/* Stats bar */
.mc-stats-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.mc-stat {
  flex: 1;
  text-align: center;
  background: #fff;
  border-radius: 10px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  transition: transform 0.15s;
}
.mc-stat:hover { transform: translateY(-1px); }
.mc-stat.pending {
  background: #fff8e1;
  border-color: #ffe082;
}
.mc-stat.done {
  background: #e8f5e9;
  border-color: #a5d6a7;
}
.mc-stat.total {
  background: #fff5f5;
  border-color: #ffcdd2;
}
.mc-stat-val {
  display: block;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}
.mc-stat.pending .mc-stat-val { color: #e65100; }
.mc-stat.done .mc-stat-val { color: #2e7d32; }
.mc-stat.total .mc-stat-val { color: #c62828; }
.mc-stat-lbl {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

/* Filter bar */
.mc-filter-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.mc-filter-btn {
  flex: 1;
  padding: 10px 12px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.mc-filter-btn:hover {
  color: var(--text);
  background: var(--bg);
}
.mc-filter-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* Missed calls list */
.mc-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  max-height: 55vh;
}
.mc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 6px;
  transition: all 0.15s;
  background: #fff;
}
.mc-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.mc-item.mc-pending {
  border-left: 3px solid #e65100;
  background: #fffaf5;
}
.mc-item.mc-done {
  border-left: 3px solid #43a047;
  background: #f9fdf9;
  opacity: 0.85;
}
.mc-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.mc-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid #ffcdd2;
}
.mc-avatar-fallback {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffebee, #ffcdd2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.mc-item-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.mc-item-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mc-item-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 2px;
  flex-wrap: wrap;
}
.mc-item-notes {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  background: #f5f7fa;
  padding: 3px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mc-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  margin-top: 3px;
}
.mc-badge-pending {
  background: #fff3e0;
  color: #e65100;
}
.mc-badge-done {
  background: #e8f5e9;
  color: #2e7d32;
}
.mc-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.mc-item-actions .btn-outline.btn-sm {
  min-width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Summary missed call section */
.summary-thread-item.missed-call-item {
  border-left: 3px solid #e53935;
  background: #fff5f5;
}
.summary-thread-item.missed-call-item:hover {
  background: #ffe8e8;
}

/* ==========================================================
   GUIDE PAGE STYLES
   ========================================================== */

/* Layout */
.guide-layout {
  display: flex;
  height: calc(100vh - 52px);
  overflow: hidden;
}
.guide-sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.guide-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  scroll-behavior: smooth;
}

/* Version toggle */
.guide-version-toggle {
  display: flex;
  padding: 12px 12px 8px;
  gap: 4px;
}
.guide-ver-btn {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.guide-ver-btn:hover {
  background: var(--surface);
  border-color: var(--primary);
  color: var(--text);
}
.guide-ver-btn.active {
  background: linear-gradient(135deg, var(--primary), #764ba2);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Search */
.guide-search {
  padding: 0 12px 8px;
}
.guide-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: var(--bg);
  box-sizing: border-box;
}
.guide-search input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

/* Table of Contents */
.guide-toc {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 16px;
}
.toc-group {
  margin-bottom: 8px;
}
.toc-group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 8px 4px;
}
.toc-item {
  display: block;
  padding: 6px 8px 6px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.toc-item:hover {
  background: var(--bg);
  color: var(--text);
}
.toc-item.active {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.06));
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
}

/* Guide sections */
.guide-section {
  padding: 32px 48px;
  border-bottom: 1px solid var(--border);
  max-width: 900px;
  margin: 0 auto;
}
.guide-section h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
  display: inline-block;
}
.guide-section h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 24px 0 12px;
}
.guide-section h4 {
  font-size: 15px;
  font-weight: 600;
  margin: 16px 0 8px;
}
.guide-section p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin: 0 0 12px;
}

/* Hero */
.guide-hero {
  text-align: center;
  padding: 40px 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  border-radius: 16px;
  margin-bottom: 24px;
  color: #fff;
}
.guide-hero-icon {
  font-size: 56px;
  margin-bottom: 12px;
}
.guide-hero h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px;
  border: none;
  padding: 0;
  display: block;
  color: #fff;
}
.guide-hero-sub {
  font-size: 16px;
  opacity: 0.9;
  color: #fff !important;
}
.guide-hero-version {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 12px;
}

/* Card */
.guide-card {
  background: var(--bg);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid var(--border);
  margin: 16px 0;
}
.guide-card h2 {
  font-size: 18px;
  margin: 0 0 12px;
  border: none;
  display: block;
}

/* List */
.guide-list {
  padding-left: 0;
  list-style: none;
  margin: 8px 0 16px;
}
.guide-list li {
  padding: 6px 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  position: relative;
  padding-left: 8px;
}

/* Notes */
.guide-note {
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.7;
  margin: 16px 0;
}
.guide-note-info {
  background: #e3f2fd;
  border-left: 4px solid #2196F3;
  color: #1565c0;
}
.guide-note-warning {
  background: #fff8e1;
  border-left: 4px solid #ff9800;
  color: #5d4037;
}
.guide-note-tip {
  background: #e8f5e9;
  border-left: 4px solid #4caf50;
  color: #1b5e20;
}

/* Steps */
.guide-steps {
  margin: 16px 0;
}
.guide-step {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  align-items: flex-start;
}
.guide-step-num {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #764ba2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}
.guide-step-content {
  flex: 1;
  padding-top: 4px;
}
.guide-step-content p {
  margin: 0 0 8px;
}

/* Code block */
.guide-code {
  display: inline-block;
  background: #1e1e2e;
  color: #a6e3a1;
  padding: 8px 16px;
  border-radius: 8px;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  margin: 8px 0;
  word-break: break-all;
}

/* Screenshots */
.guide-screenshot,
.guide-video {
  display: block;
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  margin: 16px 0;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.guide-screenshot:hover,
.guide-video:hover {
  transform: scale(1.01);
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

/* Tables */
.guide-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}
.guide-table th {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
}
.guide-table th:first-child { border-radius: 8px 0 0 0; }
.guide-table th:last-child { border-radius: 0 8px 0 0; }
.guide-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}
.guide-table tr:nth-child(even) td {
  background: var(--bg);
}
.guide-table tr:hover td {
  background: #f0f4ff;
}

/* Layout explanation cards */
.guide-layout-explain {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0;
}
.guide-area-card {
  padding: 16px 20px;
  background: var(--bg);
  border-radius: 10px;
}
.guide-area-card h4 {
  margin: 0 0 4px;
  font-size: 14px;
}
.guide-area-card p {
  margin: 0;
  font-size: 13px;
}

/* Status list */
.guide-status-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.guide-status-item {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
}

/* Feature grid */
.guide-feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0;
}
.guide-feature-card {
  padding: 16px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: transform 0.15s;
}
.guide-feature-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.guide-feature-card h4 {
  margin: 0 0 6px;
  font-size: 14px;
}
.guide-feature-card p {
  margin: 0;
  font-size: 12px;
}

/* Tips grid */
.guide-tips-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0;
}
.guide-tip-card {
  padding: 20px;
  background: linear-gradient(135deg, #fafbfc, #f0f4ff);
  border-radius: 12px;
  border: 1px solid var(--border);
  text-align: center;
  transition: transform 0.2s;
}
.guide-tip-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}
.guide-tip-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
}
.guide-tip-card h4 {
  margin: 0 0 6px;
  font-size: 14px;
}
.guide-tip-card p {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Timeline (What's New) */
.guide-timeline {
  position: relative;
  padding-left: 28px;
  margin: 16px 0;
}
.guide-timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: linear-gradient(to bottom, var(--primary), #764ba2);
}
.guide-timeline-item {
  position: relative;
  margin-bottom: 20px;
}
.guide-timeline-item::before {
  content: '';
  position: absolute;
  left: -22px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
}
.guide-timeline-date {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.guide-timeline-content h4 {
  margin: 0 0 4px;
  font-size: 14px;
}
.guide-timeline-content p {
  margin: 0;
  font-size: 13px;
}

/* Video grid */
.guide-video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 16px 0;
}
.guide-video-card {
  background: var(--bg);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.2s;
}
.guide-video-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}
.guide-video-card h4 {
  padding: 12px 16px 0;
  margin: 0;
  font-size: 14px;
}
.guide-video-card .guide-video {
  margin: 8px;
  border-radius: 8px;
  width: calc(100% - 16px);
}
.guide-video-desc {
  padding: 0 16px 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

/* FAQ */
.guide-faq {
  margin: 16px 0;
}
.guide-faq-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.guide-faq-item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.guide-faq-item.open {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}
.guide-faq-q {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  background: var(--bg);
  transition: background 0.15s;
}
.guide-faq-q:hover {
  background: #f0f4ff;
}
.guide-faq-arrow {
  color: var(--text-muted);
  font-size: 12px;
  transition: transform 0.2s;
}
.guide-faq-item.open .guide-faq-arrow {
  transform: rotate(180deg);
}
.guide-faq-a {
  padding: 0 18px 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.guide-faq-a ul {
  padding-left: 20px;
  margin: 8px 0;
}
.guide-faq-a li {
  margin-bottom: 4px;
}

/* Admin divider */
.guide-admin-divider {
  text-align: center;
  padding: 40px 20px;
  background: linear-gradient(135deg, #1e1e2e, #2d2d44);
  color: #fff;
  margin: 0;
}
.guide-admin-divider span {
  display: inline-block;
  background: linear-gradient(135deg, #667eea, #764ba2);
  padding: 10px 24px;
  border-radius: 24px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
}
.guide-admin-divider p {
  color: rgba(255,255,255,0.6) !important;
  font-size: 13px;
  margin: 8px 0 0;
}

/* Guide footer */
.guide-footer {
  text-align: center;
  padding: 40px 20px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}
.guide-footer p {
  margin: 4px 0;
  font-size: 13px;
}

/* Lightbox */
.guide-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  opacity: 0;
  transition: opacity 0.3s;
}
.guide-lightbox.visible {
  opacity: 1;
}
.guide-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
}
.guide-lightbox-content {
  position: absolute;
  inset: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.guide-lightbox-content img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.guide-lightbox-close {
  position: absolute;
  top: 0;
  right: 0;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 20px;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s;
}
.guide-lightbox-close:hover {
  background: rgba(255,0,0,0.6);
}

/* Responsive */
@media (max-width: 768px) {
  .guide-layout {
    flex-direction: column;
  }
  .guide-sidebar {
    width: 100%;
    min-width: unset;
    max-height: 300px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .guide-section {
    padding: 24px 20px;
  }
  .guide-feature-grid,
  .guide-tips-grid {
    grid-template-columns: 1fr;
  }
  .guide-video-grid {
    grid-template-columns: 1fr;
  }
  .guide-hero h1 {
    font-size: 22px;
  }
}

/* ===== Ecard / Friend Accepted Card ===== */
.msg-ecard {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  max-width: 260px;
  border: 1px solid #e0e0e0;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.2s, box-shadow 0.2s;
}
.msg-ecard:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.1);
}
.msg-ecard.friend-accepted {
  border-color: #a5d6a7;
}
.msg-ecard-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  background: linear-gradient(135deg, #43a047 0%, #66bb6a 50%, #81c784 100%);
  position: relative;
}
.msg-ecard-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 40%, rgba(255,255,255,0.15) 0%, transparent 60%);
  pointer-events: none;
}
.msg-ecard-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,0.85);
  box-shadow: 0 3px 12px rgba(0,0,0,0.2);
  position: relative;
  z-index: 1;
}
.msg-ecard-avatar-fallback {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border: 3px solid rgba(255,255,255,0.5);
}
.msg-ecard-body {
  padding: 14px 16px 14px;
  position: relative;
  background: linear-gradient(180deg, #f1f8e9 0%, #fff 100%);
}
.msg-ecard-icon-badge {
  position: absolute;
  top: -14px;
  right: 14px;
  font-size: 18px;
  background: #fff;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  border: 1px solid #e8f5e9;
}
.msg-ecard-title {
  font-weight: 700;
  font-size: 13px;
  color: #2e7d32;
  margin-bottom: 4px;
  line-height: 1.4;
}
.msg-ecard-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ===== System Info Message (msginfo.actionlist generic) ===== */
.msg-system-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f5f7fa 0%, #eef1f5 100%);
  border: 1px solid #e0e4ea;
  max-width: 320px;
}
.msg-system-info-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  flex-shrink: 0;
}
.msg-system-info-content {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.msg-system-info-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.msg-system-info-text {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
  word-break: break-word;
}

/* ==========================================================
   FRIEND REQUESTS MANAGEMENT MODAL
   ========================================================== */

.friend-requests-modal {
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

/* Badge on topbar button */
.fr-badge {
  background: linear-gradient(135deg, #e53935, #ff5252);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 3px;
  min-width: 16px;
  text-align: center;
  display: inline-block;
  line-height: 1.5;
  animation: frBadgePulse 2s ease-in-out infinite;
}
@keyframes frBadgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Stats bar */
.fr-stats-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.fr-stat {
  flex: 1;
  text-align: center;
  background: #fff;
  border-radius: 10px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  transition: transform 0.15s;
}
.fr-stat:hover { transform: translateY(-1px); }
.fr-stat.pending {
  background: linear-gradient(135deg, #fff8e1, #fff3cd);
  border-color: #ffe082;
}
.fr-stat.accepted {
  background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  border-color: #a5d6a7;
}
.fr-stat.rejected {
  background: linear-gradient(135deg, #fce4ec, #f8bbd0);
  border-color: #ef9a9a;
}
.fr-stat-val {
  display: block;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}
.fr-stat.pending .fr-stat-val { color: #e65100; }
.fr-stat.accepted .fr-stat-val { color: #2e7d32; }
.fr-stat.rejected .fr-stat-val { color: #c62828; }
.fr-stat-lbl {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

/* Filter bar */
.fr-filter-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.fr-filter-btn {
  flex: 1;
  padding: 10px 12px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.fr-filter-btn:hover {
  color: var(--text);
  background: var(--bg);
}
.fr-filter-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* Batch actions bar */
.fr-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #e3f2fd, #f0f7ff);
  border-bottom: 1px solid #bbdefb;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
}

/* Friend requests list */
.fr-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  max-height: 55vh;
}
.fr-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 6px;
  transition: all 0.15s;
  background: #fff;
}
.fr-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.fr-item.fr-pending {
  border-left: 3px solid #e67e22;
  background: #fffaf5;
}
.fr-item.fr-accepted {
  border-left: 3px solid #43a047;
  background: #f9fdf9;
  opacity: 0.85;
}
.fr-item.fr-rejected {
  border-left: 3px solid #e53935;
  background: #fff5f5;
  opacity: 0.7;
}
.fr-item-check {
  flex-shrink: 0;
}
.fr-item-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}
.fr-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid #e3f2fd;
}
.fr-avatar-fallback {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e3f2fd, #bbdefb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.fr-item-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.fr-item-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fr-item-msg {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fr-item-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 3px;
  flex-wrap: wrap;
}
.fr-item-account {
  font-size: 10px;
  color: var(--text-muted);
  background: #f0f0f0;
  padding: 1px 6px;
  border-radius: 4px;
}
.fr-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.fr-btn-accept {
  background: linear-gradient(135deg, #43a047, #66bb6a);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.fr-btn-accept:hover {
  background: linear-gradient(135deg, #388e3c, #43a047);
  box-shadow: 0 2px 8px rgba(67, 160, 71, 0.3);
  transform: translateY(-1px);
}
.fr-btn-accept:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.fr-btn-reject {
  background: #fff;
  color: #e53935;
  border: 1px solid #ffcdd2;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.fr-btn-reject:hover {
  background: #fff5f5;
  border-color: #e53935;
}
.fr-btn-reject:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.fr-status-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.fr-status-accepted {
  background: #e8f5e9;
  color: #2e7d32;
}
.fr-status-rejected {
  background: #fce4ec;
  color: #c62828;
}
.fr-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.fr-empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}
.fr-empty-text {
  font-size: 14px;
}
.fr-processing {
  pointer-events: none;
  opacity: 0.5;
}

/* ==========================================================
   TICKET CENTER PLUGIN (CRM → Ticket Tab)
   ========================================================== */

.tickets-panel { display:flex; flex-direction:column; height:100%; }
.tickets-header {
  display:flex; justify-content:space-between; align-items:center;
  padding:10px 14px; font-weight:700; font-size:14px;
  border-bottom:1px solid var(--border);
}
.tickets-hint {
  font-size:11px; color:var(--text-light);
  background:linear-gradient(135deg, #f3f0ff, #ede8ff);
  padding:8px 12px; border-radius:8px; border-left:3px solid var(--primary);
}

/* Stats bar */
.tickets-stats {
  display:flex; gap:6px; padding:8px 12px;
  border-bottom:1px solid var(--border); background:#fafbfc;
}
.ticket-stat {
  flex:1; text-align:center; font-size:11px; padding:4px 6px;
  border-radius:8px; background:#fff; border:1px solid var(--border);
}
.ticket-stat b { font-size:14px; display:block; }

/* Ticket list */
.tickets-list { flex:1; overflow-y:auto; padding:6px 10px; }

.tc-ticket-card {
  padding:10px 12px; margin-bottom:6px;
  border:1px solid var(--border); border-radius:10px;
  background:#fff; cursor:pointer;
  transition:all 0.15s;
}
.tc-ticket-card:hover {
  border-color:var(--primary);
  box-shadow:0 2px 8px rgba(0,0,0,0.06);
  transform:translateY(-1px);
}
.tc-ticket-top {
  display:flex; justify-content:space-between; align-items:center; margin-bottom:4px;
}
.tc-ticket-num {
  font-size:11px; font-weight:700; color:var(--primary);
  font-family:'SF Mono',monospace;
}
.tc-ticket-subject {
  font-size:13px; font-weight:500; margin-bottom:4px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.tc-ticket-meta {
  display:flex; gap:6px; font-size:11px; color:var(--text-light); flex-wrap:wrap;
  align-items:center;
}
.tc-ticket-tags {
  display:flex; gap:4px; margin-top:4px; flex-wrap:wrap;
}
.tc-tag {
  background:linear-gradient(135deg, #f3f0ff, #ede8ff); color:var(--primary);
  padding:1px 6px; border-radius:4px; font-size:10px; font-weight:500;
}

/* Badges */
.tc-badge {
  padding:1px 7px; border-radius:6px; font-size:10px; font-weight:600;
  white-space:nowrap;
}
.tc-status-open { background:#e8f5e9; color:#2e7d32; }
.tc-status-in_progress { background:#e3f2fd; color:#1565c0; }
.tc-status-pending { background:#fff8e1; color:#e65100; }
.tc-status-resolved { background:#f3f0ff; color:#6c5ce7; }
.tc-status-closed { background:#f5f5f5; color:#9e9e9e; }
.tc-status-failed { background:#fce4ec; color:#c62828; }
.tc-prio-0 { background:#fce4ec; color:#c62828; }
.tc-prio-1 { background:#fff8e1; color:#e65100; }
.tc-prio-2 { background:#e3f2fd; color:#1565c0; }
.tc-prio-3 { background:#e8f5e9; color:#2e7d32; }
.tc-cat { background:#f5f5f5; color:var(--text-secondary); }

/* AI Summary */
.tc-ai-summary {
  font-size:12px; color:var(--primary);
  background:linear-gradient(135deg, #f3f0ff, #ede8ff);
  padding:8px 12px; border-radius:8px; margin-bottom:12px;
  border-left:3px solid var(--primary);
}

/* Comments in detail modal */
.tc-comments { display:flex; flex-direction:column; gap:8px; }
.tc-comment {
  display:flex; gap:8px; font-size:13px;
}
.tc-comment-avatar { font-size:16px; flex-shrink:0; margin-top:2px; }
.tc-comment-body { flex:1; min-width:0; }
.tc-comment-header { font-size:12px; margin-bottom:2px; }
.tc-comment-time { font-size:10px; color:var(--text-light); margin-left:8px; }
.tc-comment-text { white-space:pre-wrap; line-height:1.5; }
.tc-comment-gpt .tc-comment-text {
  background:linear-gradient(135deg, #f3f0ff, #ede8ff);
  padding:6px 10px; border-radius:8px; border-left:3px solid var(--primary);
}
.tc-comment-system .tc-comment-text {
  background:#f5f5f5; padding:6px 10px; border-radius:8px;
  font-size:12px; color:var(--text-muted);
}

/* ==========================================================
   SERVER-SIDE DEEP SEARCH PANEL
   ========================================================== */

.server-search-panel {
  border-bottom: 2px solid var(--primary);
  background: linear-gradient(180deg, #f8f9ff 0%, #fff 100%);
  max-height: 50vh;
  overflow-y: auto;
}

.search-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: linear-gradient(135deg, #f3f0ff, #ede8ff);
  border-bottom: 1px solid #e0daf7;
  position: sticky;
  top: 0;
  z-index: 2;
}

.search-count {
  font-size: 11px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
}

.search-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-light);
}

.search-error {
  padding: 12px 16px;
  font-size: 13px;
  color: #c62828;
}

.search-info {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.search-result-item {
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.15s;
  border-bottom: 1px solid #f0f0f0;
}

.search-result-item:hover {
  background: #f0f4ff;
}

.search-result-item:active {
  background: #e3eaff;
}

.search-item-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.search-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid #e0e0e0;
}

.search-avatar-fb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e3f2fd, #bbdefb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.search-item-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.search-item-line1 {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.search-item-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.search-phone {
  font-size: 11px;
  color: var(--text-light);
  font-family: 'SF Mono', monospace;
}

.search-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-name {
  background: #e3f2fd;
  color: #1565c0;
}

.badge-alias {
  background: #f3e5f5;
  color: #7b1fa2;
}

.badge-phone {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-content {
  background: #fff3e0;
  color: #e65100;
}

.search-item-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}

.search-snippet {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 3px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 0;
}

.search-snippet mark {
  background: #fff176;
  color: #333;
  padding: 0 2px;
  border-radius: 2px;
}

.search-item-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================================
   WWG (Work with GPT) Panel
   ========================================================== */

.wwg-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.wwg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #f3f0ff 0%, #e8e4ff 100%);
  color: var(--primary);
}

/* Messages area */
.wwg-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Welcome screen */
.wwg-welcome {
  text-align: center;
  padding: 40px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.wwg-welcome-icon {
  font-size: 48px;
  animation: wwgBounce 2s ease-in-out infinite;
}

@keyframes wwgBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.wwg-welcome-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.wwg-welcome-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.wwg-welcome-examples {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  width: 100%;
  max-width: 280px;
}

.wwg-example {
  padding: 8px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
}

.wwg-example:hover {
  border-color: var(--primary);
  background: #f3f0ff;
  color: var(--primary);
  transform: translateX(4px);
}

/* Messages */
.wwg-msg {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  animation: wwgFadeIn 0.3s ease;
}

@keyframes wwgFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.wwg-msg-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 2px;
}

.wwg-msg-bubble {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.wwg-msg-user .wwg-msg-bubble {
  background: linear-gradient(135deg, var(--primary), #764ba2);
  color: #fff;
  border-bottom-left-radius: 4px;
}

.wwg-msg-assistant .wwg-msg-bubble {
  background: #f5f7fa;
  border: 1px solid #e8ecf0;
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.wwg-msg-error .wwg-msg-bubble {
  background: #fff5f5;
  border: 1px solid #ffcdd2;
  color: #c62828;
}

.wwg-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

/* Filter results in message */
.wwg-filter-results {
  margin-top: 8px;
  border: 1px solid #e0daf7;
  border-radius: 10px;
  overflow: hidden;
}

.wwg-filter-header {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  background: linear-gradient(135deg, #f3f0ff, #ede8ff);
  color: var(--primary);
  border-bottom: 1px solid #e0daf7;
}

.wwg-filter-item {
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: all 0.12s;
}

.wwg-filter-item:hover {
  background: #f0f4ff;
}

.wwg-filter-item:last-child {
  border-bottom: none;
}

.wwg-item-line1 {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.wwg-item-name {
  font-weight: 600;
  font-size: 12.5px;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wwg-item-phone {
  font-size: 10.5px;
  color: var(--text-light);
  font-family: 'SF Mono', monospace;
}

.wwg-item-time {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-left: auto;
}

.wwg-item-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.wwg-item-snippet {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wwg-filter-more {
  text-align: center;
  padding: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

/* Badges */
.wwg-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
  white-space: nowrap;
}

.wwg-badge-unseen {
  background: #e3f2fd;
  color: #1565c0;
}

.wwg-badge-unreplied {
  background: #fff3e0;
  color: #e65100;
}

.wwg-badge-urgent {
  background: #fce4ec;
  color: #c62828;
}

.wwg-badge-pending {
  background: #fff8e1;
  color: #f57f17;
}

.wwg-badge-negative {
  background: #fce4ec;
  color: #c62828;
}

/* Show on thread list button */
.wwg-show-filter-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 7px 0;
  background: linear-gradient(135deg, var(--primary), #764ba2);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.wwg-show-filter-btn:hover {
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
  transform: translateY(-1px);
}

/* Stats grid */
.wwg-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.wwg-stat-card {
  text-align: center;
  padding: 8px 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
}

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

.wwg-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

.wwg-stat-green .wwg-stat-value { color: #2e7d32; }
.wwg-stat-green { border-color: #a5d6a7; background: #f1f8e9; }
.wwg-stat-blue .wwg-stat-value { color: #1565c0; }
.wwg-stat-blue { border-color: #90caf9; background: #e3f2fd; }
.wwg-stat-orange .wwg-stat-value { color: #e65100; }
.wwg-stat-orange { border-color: #ffcc80; background: #fff3e0; }

/* Phase 4: Smart Report Cards */
.wwg-report-section {
  margin-top: 10px;
  padding: 8px 0;
  border-top: 1px solid #e3e8ee;
}
.wwg-report-section:first-of-type { border-top: none; }
.wwg-report-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Briefing Grid */
.wwg-briefing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.wwg-briefing-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  background: #f8f9fa;
  border-radius: 10px;
  border: 1px solid #e3e8ee;
  transition: all 0.2s;
}
.wwg-briefing-item.wwg-briefing-active {
  background: #fff;
  border-color: #90caf9;
  box-shadow: 0 1px 4px rgba(25, 118, 210, 0.08);
}
.wwg-briefing-icon { font-size: 16px; }
.wwg-briefing-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.wwg-briefing-active .wwg-briefing-value { color: #1565c0; }
.wwg-briefing-label {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
}

/* Suggestions */
.wwg-suggestions { margin-top: 4px; }
.wwg-suggestion-item {
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text);
  background: linear-gradient(135deg, #fffde7 0%, #fff8e1 100%);
  border-left: 3px solid #ffc107;
  border-radius: 4px;
  margin-bottom: 4px;
}

/* Table */
.wwg-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 4px;
}
.wwg-table th {
  background: #f0f2f5;
  padding: 6px 8px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid #dee2e6;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.wwg-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f0f2f5;
  color: var(--text);
}
.wwg-table tbody tr:hover { background: #f8f9fa; }
.wwg-row-highlight { background: #fffde7 !important; }
.wwg-row-highlight td { font-weight: 600; }

/* Rate indicators */
.wwg-rate-good { color: #2e7d32; font-weight: 700; }
.wwg-rate-ok { color: #e65100; font-weight: 700; }
.wwg-rate-bad { color: #c62828; font-weight: 700; }

/* Lifecycle items */
.wwg-lifecycle-list { margin-top: 8px; }
.wwg-lifecycle-item {
  padding: 8px 10px;
  border: 1px solid #e3e8ee;
  border-radius: 10px;
  margin-bottom: 5px;
  background: #fff;
  transition: all 0.2s;
}
.wwg-lifecycle-item.wwg-clickable { cursor: pointer; }
.wwg-lifecycle-item.wwg-clickable:hover {
  background: #e3f2fd;
  border-color: #90caf9;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.wwg-lifecycle-line1 {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 13px;
}
.wwg-lifecycle-line2 {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}
.wwg-badge-ok {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}
.wwg-badge-dormant {
  background: #fce4ec;
  color: #c62828;
  border: 1px solid #ef9a9a;
}
.wwg-empty {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-style: italic;
}

/* Input area */
.wwg-input-area {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}

.wwg-input-area textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  min-height: 36px;
  max-height: 100px;
}

.wwg-input-area textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.wwg-send-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: linear-gradient(135deg, var(--primary), #764ba2);
  color: #fff;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.wwg-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.wwg-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* WWG Filter Banner on Thread List */
.wwg-filter-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: linear-gradient(135deg, #f3f0ff, #ede8ff);
  border-bottom: 2px solid var(--primary);
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

.wwg-filter-banner button {
  background: none;
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.wwg-filter-banner button:hover {
  background: var(--primary);
  color: #fff;
}

/* ===== Phase 2: Action Preview/Confirm/Rollback ===== */

.wwg-action-desc {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #fff8e1, #fff3e0);
  border: 1px solid #ffe082;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #e65100;
}

.wwg-action-icon {
  font-size: 18px;
}

.wwg-action-warning {
  margin-top: 8px;
  padding: 8px 12px;
  background: #fff5f5;
  border: 1px solid #ffcdd2;
  border-radius: 8px;
  font-size: 12px;
  color: #c62828;
}

.wwg-action-buttons {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.wwg-confirm-btn {
  flex: 1;
  padding: 10px 16px;
  background: #bdbdbd;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: not-allowed;
  transition: all 0.3s;
}

.wwg-confirm-btn:disabled {
  opacity: 0.7;
}

.wwg-confirm-btn.wwg-confirm-ready {
  background: linear-gradient(135deg, #43a047, #66bb6a);
  cursor: pointer;
  animation: wwgPulse 1.5s ease-in-out infinite;
}

.wwg-confirm-btn.wwg-confirm-ready:hover {
  box-shadow: 0 3px 12px rgba(67, 160, 71, 0.4);
  transform: translateY(-1px);
}

@keyframes wwgPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(67, 160, 71, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(67, 160, 71, 0); }
}

.wwg-cancel-btn {
  padding: 10px 16px;
  background: #fff;
  color: #e53935;
  border: 1px solid #ffcdd2;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.wwg-cancel-btn:hover {
  background: #fff5f5;
  border-color: #e53935;
}

.wwg-action-success {
  margin-top: 8px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
  border: 1px solid #a5d6a7;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #2e7d32;
}

.wwg-rollback-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 14px;
  background: #fff;
  color: var(--primary);
  border: 1px solid #d1c4e9;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.wwg-rollback-btn:hover {
  background: #f3f0ff;
  border-color: var(--primary);
  transform: translateY(-1px);
}

.wwg-action-error {
  margin-top: 8px;
  padding: 10px 14px;
  background: #fff5f5;
  border: 1px solid #ffcdd2;
  border-radius: 10px;
  font-size: 13px;
  color: #c62828;
}

.wwg-action-cancelled {
  margin-top: 8px;
  padding: 8px 14px;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.wwg-action-empty {
  margin-top: 8px;
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ===== Server-Side Deep Search Panel ===== */
.server-search-panel {
  background: linear-gradient(135deg, #f0f7ff 0%, #e8f0fe 100%);
  border-bottom: 2px solid var(--primary-lighter, #b3d4fc);
  padding: 6px 8px;
  max-height: 300px;
  overflow-y: auto;
  display: none;
}

.server-search-panel .search-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary, #4a6cf7);
}

.server-search-panel .search-count {
  background: var(--primary, #4a6cf7);
  color: #fff;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.server-search-panel .search-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.server-search-panel .search-loading .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--primary-lighter, #b3d4fc);
  border-top-color: var(--primary, #4a6cf7);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.server-search-panel .search-info,
.server-search-panel .search-error {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.server-search-panel .search-error {
  color: var(--danger, #e53935);
}

.search-result-item {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.search-result-item:hover {
  background: rgba(74, 108, 247, 0.08);
}

.search-item-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.search-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.search-avatar-fb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.search-item-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.search-item-line1 {
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-item-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text, #1a1a2e);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-phone {
  font-size: 11px;
  color: var(--primary, #4a6cf7);
  font-weight: 500;
}

.search-item-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
}

.search-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  white-space: nowrap;
}

.badge-phone {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-content {
  background: #fff3e0;
  color: #e65100;
}

.badge-alias {
  background: #e3f2fd;
  color: #1565c0;
}

.badge-name {
  background: #f3e5f5;
  color: #7b1fa2;
}

.search-snippet {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-snippet b {
  color: var(--text);
}

.search-snippet .highlight {
  background: rgba(255, 213, 79, 0.4);
  border-radius: 2px;
  padding: 0 1px;
}
/* ===== Advanced Filter Modal ===== */
.advanced-filter-modal {
  width: 550px;
  max-width: 95vw;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  overflow: hidden;
}
.af-body {
  padding: 20px 24px;
}
.af-group {
  margin-bottom: 20px;
}
.af-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
}
.af-group input[type="text"],
.af-group input[type="date"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-hover);
  color: var(--text);
  transition: border-color 0.2s;
}
.af-group input[type="text"]:focus,
.af-group input[type="date"]:focus {
  border-color: #0068ff;
  outline: none;
}
.af-row {
  display: flex;
  gap: 16px;
}
.af-row .af-group {
  flex: 1;
  margin-bottom: 0;
}
/* Chip Grid */
.af-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.af-chip {
  display: block;
  cursor: pointer;
  user-select: none;
}
.af-chip input[type="checkbox"] {
  display: none; /* hide default checkbox */
}
.af-chip span {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  transition: all 0.2s ease;
  white-space: nowrap;
}
.af-chip span:hover {
  background: var(--bg-hover);
}
.af-chip input[type="checkbox"]:checked + span {
  background: rgba(0, 104, 255, 0.08);
  border-color: #0068ff;
  color: #0068ff;
  font-weight: 500;
}
.af-footer {
  padding: 16px 24px;
  background: var(--bg-hover);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ===== CRM Topbar Dialpad ===== */
.crm-dialpad-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 9998;
}

.crm-dialpad-panel {
  position: fixed;
  top: 48px;
  right: 80px;
  width: 260px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  z-index: 9999;
  overflow: hidden;
  animation: dialpadSlideIn 0.18s ease-out;
}

@keyframes dialpadSlideIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.crm-dialpad-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(135deg, #43a047, #66bb6a);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.crm-dialpad-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background 0.15s;
}

.crm-dialpad-close:hover {
  background: rgba(255,255,255,0.2);
}

.crm-dialpad-display {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  gap: 6px;
  border-bottom: 1px solid #e3e8ee;
}

.crm-dialpad-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 20px;
  font-weight: 600;
  font-family: 'SF Mono', 'Consolas', monospace;
  letter-spacing: 1.5px;
  color: #1a1a2e;
  background: transparent;
  text-align: center;
}

.crm-dialpad-input::placeholder {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  color: #adb5bd;
}

.crm-dialpad-backspace {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #666;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}

.crm-dialpad-backspace:hover {
  background: #f0f2f5;
  color: #e53935;
}

.crm-dialpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px 14px;
}

.crm-dialpad-key {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  border: none;
  border-radius: 10px;
  background: #f5f7fa;
  cursor: pointer;
  transition: all 0.12s;
  min-height: 46px;
}

.crm-dialpad-key:hover {
  background: #e3f2fd;
  transform: scale(1.04);
}

.crm-dialpad-key:active {
  background: #bbdefb;
  transform: scale(0.96);
}

.crm-dialpad-key .key-num {
  font-size: 20px;
  font-weight: 600;
  color: #1a1a2e;
  line-height: 1;
}

.crm-dialpad-key .key-letters {
  font-size: 9px;
  font-weight: 500;
  color: #90a4ae;
  letter-spacing: 1.5px;
  margin-top: 2px;
}

.crm-dialpad-actions {
  display: flex;
  gap: 8px;
  padding: 8px 14px 12px;
}

.crm-dialpad-call {
  flex: 1;
  padding: 10px 0;
  background: linear-gradient(135deg, #43a047, #66bb6a);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.crm-dialpad-call:hover {
  box-shadow: 0 3px 12px rgba(67,160,71,0.35);
  transform: translateY(-1px);
}

.crm-dialpad-clear {
  padding: 10px 16px;
  background: #f5f5f5;
  color: #666;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.crm-dialpad-clear:hover {
  background: #e0e0e0;
  color: #333;
}

/* ===== Thread Tab Bar (Chrome-style) ===== */
.thread-tab-bar {
  display: flex;
  align-items: stretch;
  background: linear-gradient(180deg, #f0f2f5 0%, #e8eaed 100%);
  border-bottom: 1px solid #d1d5db;
  min-height: 36px;
  position: relative;
  user-select: none;
  flex-shrink: 0;
}

.thread-tabs-scroll {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  scrollbar-width: none;
  -ms-overflow-style: none;
  gap: 1px;
  padding: 3px 3px 0;
}

.thread-tabs-scroll::-webkit-scrollbar {
  display: none;
}

.thread-tab-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 5px 12px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
  color: #5f6368;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  transition: all 0.15s ease;
  max-width: 180px;
  min-width: 80px;
  position: relative;
}

.thread-tab-item:hover {
  background: rgba(255,255,255,0.6);
  color: #333;
}

.thread-tab-item.active {
  background: #fff;
  color: #1a1a2e;
  font-weight: 600;
  border-color: #d1d5db;
  box-shadow: 0 -1px 3px rgba(0,0,0,0.06);
  z-index: 1;
}

/* Active tab covers the bottom border of the bar */
.thread-tab-item.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: #fff;
}

.thread-tab-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.thread-tab-avatar-fb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}

.thread-tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.thread-tab-close {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #999;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: all 0.15s;
  background: transparent;
  border: none;
  padding: 0;
  line-height: 1;
}

.thread-tab-item:hover .thread-tab-close,
.thread-tab-item.active .thread-tab-close {
  opacity: 1;
}

.thread-tab-close:hover {
  background: #e53935;
  color: #fff;
}

/* Unseen indicator dot */
.thread-tab-item.tab-unseen .thread-tab-name {
  font-weight: 700;
  color: #1565c0;
}

.thread-tab-item.tab-unseen::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1565c0;
  flex-shrink: 0;
}

/* Unreplied */
.thread-tab-item.tab-unreplied .thread-tab-name {
  color: #e65100;
}

/* ===== Recent Activity Panel ===== */
.topbar-ra-wrapper {
  position: relative;
  display: inline-block;
}

.recent-activity-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 420px;
  max-height: 520px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.06);
  z-index: 9000;
  overflow: hidden;
  animation: raPanelIn 0.18s ease-out;
}

@keyframes raPanelIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ra-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
}

.ra-header-title {
  font-weight: 600;
  font-size: 14px;
}

.ra-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  background: #f5f6fa;
  border-bottom: 1px solid #e3e8ee;
  overflow-x: auto;
}

.ra-tab {
  padding: 5px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #666;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.ra-tab:hover {
  background: #e8eaef;
}

.ra-tab.active {
  background: #fff;
  color: #667eea;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.ra-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 4px 0;
}

.ra-loading, .ra-empty {
  padding: 30px 20px;
  text-align: center;
  color: #999;
  font-size: 13px;
}

.ra-item {
  display: flex;
  align-items: flex-start;
  padding: 8px 12px;
  transition: background 0.12s;
  border-bottom: 1px solid #f0f2f5;
}

.ra-item:hover {
  background: #f5f7ff;
}

.ra-item-left {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.ra-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.ra-avatar-fallback {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.ra-item-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.ra-item-name {
  font-weight: 600;
  font-size: 13px;
  color: #1a1a2e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ra-item-content {
  font-size: 12px;
  color: #666;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ra-item-meta {
  display: flex;
  gap: 8px;
  margin-top: 3px;
  font-size: 11px;
  color: #999;
}

.ra-acct {
  background: #e8f5e9;
  color: #2e7d32;
  padding: 0 5px;
  border-radius: 4px;
  font-weight: 500;
  font-size: 10px;
}

.ra-time {
  color: #aaa;
}

/* ===== OrderHub Tabs (Order v2 / Invoice v2) ===== */
.oh-panel {
  padding: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.oh-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.oh-header small {
  color: rgba(255,255,255,0.6) !important;
}

.oh-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.oh-error {
  padding: 20px;
  text-align: center;
  color: #e53935;
  font-size: 13px;
}

/* ─── OrderHub Card ─── */
.oh-card {
  background: #fff;
  border: 1px solid #e3e8ee;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.oh-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 2px 8px rgba(59,130,246,0.12);
}

.oh-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.oh-card-code {
  font-weight: 700;
  font-size: 13px;
  color: #1e3a5f;
  font-family: 'SF Mono', 'Consolas', monospace;
  letter-spacing: 0.3px;
}

.oh-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  color: #64748b;
}

.oh-card-time { color: #94a3b8; }
.oh-card-count { color: #6366f1; font-weight: 500; }
.oh-card-cod { color: #059669; font-weight: 600; }

.oh-card-summary {
  font-size: 12px;
  color: #475569;
  margin-bottom: 8px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.oh-card-tracking {
  font-size: 12px;
  color: #0284c7;
  font-weight: 500;
  margin-bottom: 6px;
  font-family: 'SF Mono', 'Consolas', monospace;
}

.oh-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}

/* ─── OrderHub Buttons ─── */
.oh-btn {
  padding: 5px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  background: #f8fafc;
  color: #334155;
  white-space: nowrap;
}

.oh-btn:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.oh-btn-send {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  border-color: #059669;
}

.oh-btn-send:hover {
  background: linear-gradient(135deg, #047857, #059669);
  box-shadow: 0 2px 6px rgba(5,150,105,0.25);
}

.oh-btn-okchot {
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  color: #fff;
  border-color: #7c3aed;
}

.oh-btn-okchot:hover {
  background: linear-gradient(135deg, #6d28d9, #7c3aed);
  box-shadow: 0 2px 6px rgba(124,58,237,0.25);
}

.oh-btn-open {
  background: #fff;
  color: #2563eb;
  border-color: #93c5fd;
}

.oh-btn-open:hover {
  background: #eff6ff;
  border-color: #3b82f6;
}

/* ─── OrderHub Status Badges ─── */
.oh-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.oh-st-draft {
  background: #f1f5f9;
  color: #64748b;
}

.oh-st-unconfirmed {
  background: #fef3c7;
  color: #b45309;
}

.oh-st-confirmed {
  background: #d1fae5;
  color: #065f46;
}

.oh-st-waiting {
  background: #ede9fe;
  color: #6d28d9;
}

.oh-st-invoiced {
  background: #dbeafe;
  color: #1e40af;
}

.oh-st-cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.oh-st-processing {
  background: #e0e7ff;
  color: #4338ca;
}

.oh-st-shipped {
  background: #cffafe;
  color: #0e7490;
}

.oh-st-completed {
  background: #d1fae5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.oh-st-returned {
  background: #ffedd5;
  color: #c2410c;
}

/* ===== Customer Memory Tab (CME) ===== */
.memory-panel {
  padding: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.memory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

#memoryContent {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

/* Profile Card */
.mem-profile-card {
  background: linear-gradient(135deg, #f0f4ff 0%, #e8ecfc 100%);
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.mem-profile-main {
  margin-bottom: 10px;
}

.mem-profile-name {
  font-size: 16px;
  font-weight: 700;
  color: #1e1b4b;
}

.mem-profile-phone {
  font-size: 13px;
  color: #4338ca;
  margin-top: 3px;
  font-weight: 500;
}

.mem-stats-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.mem-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e0e7ff;
  min-width: 55px;
}

.mem-stat-val {
  font-size: 16px;
  font-weight: 700;
  color: #1e3a5f;
}

.mem-stat-lbl {
  font-size: 10px;
  color: #64748b;
  margin-top: 2px;
  white-space: nowrap;
}

.mem-sentiment-positive { color: #059669; }
.mem-sentiment-negative { color: #dc2626; }
.mem-sentiment-neutral { color: #6b7280; }

.mem-products-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.mem-products-label {
  font-size: 12px;
  color: #475569;
  font-weight: 500;
  margin-right: 2px;
}

.mem-pill {
  display: inline-block;
  padding: 2px 8px;
  background: #ede9fe;
  color: #5b21b6;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  font-family: 'SF Mono', 'Consolas', monospace;
}

/* Section titles */
.mem-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  padding: 8px 4px 6px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.mem-collapse-icon {
  font-size: 10px;
  color: #9ca3af;
  transition: transform 0.2s;
}

.mem-narrative.collapsed .mem-collapse-icon {
  transform: rotate(-90deg);
}

.mem-narrative.collapsed .mem-narrative-body {
  display: none;
}

/* Narrative */
.mem-narrative {
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 4px 12px 10px;
  margin-bottom: 10px;
}

.mem-narrative-body {
  padding: 0;
}

.mem-narrative-line {
  font-size: 12px;
  color: #713f12;
  line-height: 1.6;
  padding: 2px 0;
}

/* Working Memory */
.mem-working {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 4px 12px 10px;
  margin-bottom: 10px;
}

.mem-working-empty {
  font-size: 12px;
  color: #6b7280;
  padding: 4px 0;
}

.mem-working-group {
  padding: 4px 0;
  font-size: 12px;
  color: #166534;
}

.mem-working-label {
  font-weight: 600;
  margin-right: 4px;
}

.mem-working-detail {
  margin-top: 4px;
  padding-left: 8px;
}

.mem-working-ticket {
  font-size: 11px;
  color: #475569;
  padding: 2px 0;
}

/* Timeline */
.mem-timeline {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 4px 12px 10px;
}

.mem-timeline-empty {
  font-size: 12px;
  color: #9ca3af;
  padding: 8px 0;
}

.mem-timeline-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #f3f4f6;
}

.mem-timeline-item:last-child {
  border-bottom: none;
}

.mem-tl-icon {
  flex-shrink: 0;
  font-size: 14px;
  width: 20px;
  text-align: center;
}

.mem-tl-date {
  flex-shrink: 0;
  font-size: 11px;
  color: #9ca3af;
  font-weight: 500;
  width: 38px;
  font-family: 'SF Mono', 'Consolas', monospace;
}

.mem-tl-text {
  font-size: 12px;
  color: #374151;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

/* Error / No lead */
.mem-error {
  padding: 20px;
  text-align: center;
  color: #e53935;
  font-size: 13px;
}

.mem-no-lead {
  text-align: center;
  padding: 30px 20px;
}

.mem-no-lead-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.mem-no-lead-text {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.mem-no-lead-hint {
  font-size: 12px;
  color: #9ca3af;
}

/* ===== Help Desk Widget ===== */
#helpdesk-widget {
  position: fixed;
  bottom: 25vh;
  right: 24px;
  z-index: 99999;
  font-family: var(--font);
}

/* Bubble Button */
#hd-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4), 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  position: relative;
  z-index: 2;
}
#hd-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(102, 126, 234, 0.5), 0 4px 12px rgba(0,0,0,0.2);
}
#hd-bubble.hd-bubble-active {
  transform: scale(0.9);
  opacity: 0.6;
}
.hd-bubble-icon {
  font-size: 26px;
  line-height: 1;
}
.hd-bubble-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(102, 126, 234, 0.5);
  animation: hd-pulse 2s ease-in-out infinite;
}
@keyframes hd-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0; }
}

/* Chat Panel */
#hd-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 400px;
  max-height: 580px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  transform-origin: bottom right;
}
#hd-panel.hd-panel-hidden {
  transform: scale(0.8) translateY(20px);
  opacity: 0;
  pointer-events: none;
}
#hd-panel.hd-panel-visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Header */
.hd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  flex-shrink: 0;
}
.hd-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hd-header-icon {
  font-size: 22px;
}
.hd-header-title {
  font-weight: 600;
  font-size: 15px;
}
.hd-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}
.hd-btn-close, .hd-btn-clear {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
}
.hd-btn-close:hover, .hd-btn-clear:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* Messages Area */
.hd-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 300px;
  max-height: 420px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8f9fb;
}

/* Welcome */
.hd-welcome {
  text-align: center;
  padding: 20px 8px;
}
.hd-welcome-icon {
  font-size: 42px;
  margin-bottom: 12px;
}
.hd-welcome-text {
  color: #555;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* Suggestions */
.hd-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.hd-suggestion {
  background: #fff;
  border: 1px solid #e0e3e8;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  color: #444;
  transition: all 0.2s;
  white-space: nowrap;
}
.hd-suggestion:hover {
  background: #667eea;
  color: #fff;
  border-color: #667eea;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Message Bubbles */
.hd-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: hd-fadeIn 0.3s ease;
}
@keyframes hd-fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.hd-msg-user {
  align-self: flex-end;
}
.hd-msg-assistant {
  align-self: flex-start;
}
.hd-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.hd-msg-user .hd-msg-bubble {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.hd-msg-assistant .hd-msg-bubble {
  background: #fff;
  color: #333;
  border: 1px solid #e8eaed;
  border-bottom-left-radius: 4px;
}
.hd-msg-assistant .hd-msg-bubble strong {
  color: #1a1a2e;
}
.hd-msg-assistant .hd-msg-bubble code {
  background: #f0f1f3;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  color: #764ba2;
}
.hd-msg-assistant .hd-msg-bubble pre {
  background: #1e1e2e;
  color: #a6e3a1;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12px;
  margin: 6px 0;
}
.hd-msg-assistant .hd-msg-bubble pre code {
  background: none;
  color: inherit;
  padding: 0;
}
.hd-msg-assistant .hd-msg-bubble ul {
  margin: 4px 0;
  padding-left: 18px;
}
.hd-msg-assistant .hd-msg-bubble li {
  margin-bottom: 3px;
}

/* Tool Badges */
.hd-tool-badges {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.hd-tool-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f0f1ff, #e8eaff);
  color: #5b5fc7;
  font-weight: 500;
  border: 1px solid #d8daff;
}

/* Loading */
.hd-msg-loading {
  color: #888;
  font-style: italic;
}
.hd-dots span {
  animation: hd-blink 1.4s infinite;
  font-size: 18px;
  font-weight: bold;
}
.hd-dots span:nth-child(2) { animation-delay: 0.2s; }
.hd-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes hd-blink {
  0%, 20% { opacity: 0.2; }
  50% { opacity: 1; }
  100% { opacity: 0.2; }
}

/* Input Area */
.hd-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #e8eaed;
  background: #fff;
  flex-shrink: 0;
}
#hd-input {
  flex: 1;
  border: 1px solid #e0e3e8;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  resize: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  max-height: 120px;
  line-height: 1.4;
  background: #f8f9fb;
}
#hd-input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
  background: #fff;
}
#hd-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
}
#hd-send:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}
#hd-send:active {
  transform: scale(0.95);
}

/* Responsive */
@media (max-width: 480px) {
  #helpdesk-widget {
    bottom: 12px;
    right: 12px;
  }
  #hd-panel {
    width: calc(100vw - 24px);
    max-height: 70vh;
    right: -12px;
  }
  #hd-bubble {
    width: 48px;
    height: 48px;
  }
  .hd-bubble-icon {
    font-size: 22px;
  }
}

