/* ===== 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;
}

.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.active { background: #e7f3ff; border-left: 3px solid var(--primary); }
.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-open { background: #e8f5e9; color: #2e7d32; }
.badge-pending { background: #fff8e1; color: #f57f17; }
.badge-closed { background: #f5f5f5; color: #757575; }
.badge-urgent { background: #ffebee; color: #c62828; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.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;
}

/* 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: #e65100;
  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:not(:disabled) { background: #f5f5f5; }
.btn-outline:disabled { opacity: 0.45; cursor: not-allowed; }

.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; }

/* 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;
}
.composer textarea:focus { border-color: var(--primary); background: #fff; }
.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;
}
.msg-sticker { max-width: 120px; max-height: 120px; }

/* ===== 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; }

/* ===== 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;
}
.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-pinned { background: #f3e5f5; color: #7b1fa2; }

/* ===== 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;
}

/* ===== 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;
}

/* ===== 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;
}

/* ===== API Tool Cards (Settings > Plugins) ===== */
.settings-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color, #e5e7eb);
}

.settings-section-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #111827);
}

.api-tool-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.api-tool-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-secondary, #f9fafb);
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 8px;
  gap: 12px;
}

.api-tool-item.disabled {
  opacity: 0.55;
}

.api-tool-info {
  flex: 1;
  min-width: 0;
}

.api-tool-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary, #111827);
  display: flex;
  align-items: center;
  gap: 8px;
}

.api-tool-name .method-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-light, #dbeafe);
  color: var(--accent, #2563eb);
}

.api-tool-desc {
  font-size: 13px;
  color: var(--text-secondary, #6b7280);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.api-tool-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.api-tool-toggle {
  cursor: pointer;
  font-size: 20px;
  user-select: none;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 4px;
  color: var(--text-secondary, #6b7280);
  transition: background 0.15s;
}

.btn-icon:hover {
  background: var(--bg-hover, #f3f4f6);
  color: var(--text-primary, #111827);
}

.btn-icon.danger:hover {
  background: #fee2e2;
  color: #dc2626;
}


/* ===== Zalo OA Settings ===== */
.oa-account-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-card, #fff); border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 12px;
  transition: box-shadow 0.2s;
}
.oa-account-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.oa-account-info { display: flex; align-items: center; gap: 14px; }
.oa-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.oa-avatar-placeholder { width: 48px; height: 48px; border-radius: 50%; background: #e0e7ff; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.oa-account-details { display: flex; flex-direction: column; gap: 2px; }
.oa-name { font-weight: 600; font-size: 15px; }
.oa-id { font-size: 12px; color: #6b7280; }
.oa-status { margin-top: 4px; }
.oa-warn { font-size: 12px; color: #d97706; margin-top: 4px; }
.oa-account-actions { display: flex; align-items: center; gap: 12px; }
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: #ccc; border-radius: 22px; transition: .3s; }
.toggle-slider::before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: .3s; }
.toggle-switch input:checked + .toggle-slider { background: #22c55e; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* Drag list */
.drag-list { border: 1px solid var(--border, #e5e7eb); border-radius: 10px; overflow: hidden; }
.drag-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: #fff; border-bottom: 1px solid #f3f4f6;
  cursor: grab; transition: background 0.15s;
  user-select: none;
}
.drag-item:last-child { border-bottom: none; }
.drag-item:hover { background: #f9fafb; }
.drag-item.dragging { opacity: 0.4; background: #eff6ff; }
.drag-item.drag-over { background: #dbeafe; border-top: 2px solid #3b82f6; }
.drag-item-disabled { opacity: 0.5; }
.drag-handle { color: #9ca3af; font-size: 16px; cursor: grab; }
.drag-order { width: 24px; color: #6b7280; font-size: 13px; font-weight: 600; }
.drag-icon { font-size: 18px; }
.drag-label { flex: 1; font-size: 14px; font-weight: 500; }

.badge-green { background: #dcfce7; color: #166534; padding: 2px 8px; border-radius: 12px; font-size: 11px; }
.badge-yellow { background: #fef9c3; color: #854d0e; padding: 2px 8px; border-radius: 12px; font-size: 11px; }
.badge-red { background: #fee2e2; color: #991b1b; padding: 2px 8px; border-radius: 12px; font-size: 11px; }
.badge-gray { background: #f3f4f6; color: #6b7280; padding: 2px 8px; border-radius: 12px; font-size: 11px; }

.status-success { color: #166534; font-size: 13px; }
.status-error { color: #991b1b; font-size: 13px; }

/* ===== OA Channel Selector (Composer) ===== */
.channel-selector-wrap { margin-bottom: 8px; }
.channel-selector {
  padding: 5px 10px; border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px; font-size: 13px; background: #f9fafb;
  cursor: pointer; outline: none;
}
.channel-selector:focus { border-color: #3b82f6; }
.channel-hint { font-size: 11px; color: #6b7280; margin-top: 3px; }
.channel-hint-warn { color: #d97706; }

/* ===== OA Quota Warning Banner ===== */
.oa-quota-banner {
  padding: 7px 12px; border-radius: 8px; font-size: 12px;
  margin-bottom: 8px; font-weight: 500;
}
.oa-quota-low { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.oa-quota-paid { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.oa-quota-exhausted { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ===== Message Channel Badge ===== */
.msg-channel-badge {
  display: inline-block; font-size: 10px; padding: 1px 6px;
  border-radius: 10px; margin-bottom: 3px; font-weight: 500;
}
.msg-channel-oa { background: #dbeafe; color: #1d4ed8; }
.msg-channel-personal { background: #dcfce7; color: #166534; }

/* ===== Thread List Channel Badge ===== */
.thread-channel-badge {
  display: inline-block; font-size: 10px; padding: 1px 5px;
  border-radius: 8px; margin-left: 4px; vertical-align: middle;
}
.thread-channel-badge.oa { background: #dbeafe; color: #1d4ed8; }
