
/* VERSION: 2026-07-03-v2 */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #4F6EF7;
  --primary-light: #E8EDFE;
  --primary-dark: #3B54D4;
  --bg: #F5F6FA;
  --card: #FFFFFF;
  --text: #1A1A2E;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --border: #E5E7EB;
  --border-light: #F3F4F6;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --online: #10B981;
  --offline: #9CA3AF;
  --shadow-xs: 0 1px 1px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --sidebar-w: 170px;
  --topbar-h: 48px;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}
.sidebar-logo {
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-logo .icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.sidebar-logo .icon svg { width: 24px; height: 24px; }
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.sidebar-section {
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin: 1px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all 0.1s var(--ease-out);
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}
.nav-item .nav-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-item .nav-icon svg { width: 18px; height: 18px; }
.nav-badge { display:inline-block; background:#DC2626; color:#fff; font-size:10px; min-width:18px; height:18px; line-height:18px; text-align:center; border-radius:9px; padding:0 5px; margin-left:6px; font-weight:600; }
.nav-badge:empty { display:none; }
.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.sidebar-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
}

/* ---------- SIDEBAR COLLAPSE ---------- */
.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .sidebar-logo .logo-text { display: none; }
.sidebar.collapsed .sidebar-logo { padding: 16px 10px; justify-content: center; }
.sidebar.collapsed .sidebar-section { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 9px 0; margin: 2px 8px; }
.sidebar.collapsed .nav-item .nav-text,
.sidebar.collapsed .nav-item .badge { display: none; }
.sidebar.collapsed .sidebar-footer { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .sidebar-footer div:last-child { display: none; }

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  border-top: 1px solid var(--border-light);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  transition: all 0.15s;
  user-select: none;
}
.sidebar-toggle:hover { color: var(--primary); background: var(--bg); }
.sidebar.collapsed .sidebar-toggle .toggle-label { display: none; }

/* ---------- MAIN ---------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Toolbar */
.toolbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  flex-shrink: 0;
}
.toolbar-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}
.notes-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--card);
  transition: all 0.2s;
  user-select: none;
}
.notes-toggle:hover { border-color: var(--primary); color: var(--primary); }
.notes-toggle.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.notes-toggle .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.notes-toggle.active .dot { background: #fff; }
/* Role buttons in toolbar */
.role-btn {
  padding: 4px 14px; border: 1px solid var(--border); border-radius: 18px;
  font-size: 12px; font-weight: 500; cursor: pointer; background: var(--card);
  color: var(--text-muted); transition: all 0.2s; outline: none;
}
.role-btn:hover { border-color: var(--primary); color: var(--primary); }
.role-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
/* Dept tabs */
.dept-tab { padding: 4px 14px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; cursor: pointer; background: var(--card); color: var(--text-secondary); transition: all 0.2s; }
.dept-tab:hover { border-color: var(--primary); }
.dept-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 500; }
/* Status & Priority badges */
.tag-pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.tag-pill.red { background: #FEE2E2; color: #DC2626; }
.tag-pill.orange { background: #FFF7ED; color: #EA580C; }
.tag-pill.blue { background: #EFF6FF; color: #2563EB; }
.tag-pill.green { background: #F0FDF4; color: #16A34A; }
.tag-pill.gray { background: #F3F4F6; color: #6B7280; }
/* Action button colors */
.btn-green { background: #16A34A; color: #fff; border-color: #16A34A; }
.btn-green:hover { background: #15803D; }
.btn-gray { background: #F3F4F6; color: #6B7280; border: 1px solid #D1D5DB; }
.btn-gray:hover { background: #E5E7EB; }
/* Ticket detail drawer */
#ticketDrawer { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; }
#ticketDrawer.open { display: flex; }
.drawer-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.3); }
.drawer-panel { position: absolute; top: 0; right: 0; width: 70%; max-width: 900px; height: 100%; background: var(--card); box-shadow: -4px 0 20px rgba(0,0,0,0.1); display: flex; flex-direction: column; animation: slideIn 0.25s ease; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
/* CRM drawer - slides from left */
#crmDrawer { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; }
#crmDrawer.open { display: flex; }
.crm-drawer-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.3); }
.crm-drawer-panel { position: absolute; top: 0; right: 0; width: 70%; max-width: 950px; height: 100%; background: var(--card); box-shadow: -4px 0 20px rgba(0,0,0,0.1); display: flex; flex-direction: column; animation: slideInLeft 0.25s ease; }
@keyframes slideInLeft { from { transform: translateX(100%); } to { transform: translateX(0); } }
/* AI compare drawer shares styles with ticket drawer */
#aiCompareDrawer { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; }
#aiCompareDrawer.open { display: flex; }
#aiCompareDrawer .drawer-overlay { opacity: 1; }
#aiCompareDrawer .drawer-panel { right: 0; }

/* Content */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Page */
.page { display: none; }
.page.active { display: block; }

/* ---------- CARDS ---------- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-xs);
  transition: all 0.15s var(--ease-out);
  position: relative;
  border: 1px solid var(--border-light);
}
.stat-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.stat-card .stat-label { font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 500; display:flex; align-items:center; gap:4px; }
.stat-card .stat-label .ico { width:14px; height:14px; flex-shrink:0; }
.stat-card .stat-value { font-size: 24px; font-weight: 600; }
.stat-card .stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.stat-card .stat-icon {
  position: absolute;
  right: 18px; top: 16px;
  font-size: 22px; opacity: 0.2;
}
/* Row layout stat card with icon */
.stat-card-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}
.stat-card-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card-icon .ico-lg { width: 22px; height: 22px; }
.stat-card-body { text-align: left; }
.stat-card-body .stat-label { margin-bottom: 2px; }
.stat-card-body .stat-value { font-size: 22px; line-height: 1; margin-bottom: 2px; }

/* ---------- TABLES ---------- */
.data-table-wrap {
  background: var(--card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}
.table-header h3 { font-size: 14px; font-weight: 600; }
.table-header .actions { display: flex; gap: 8px; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 7px 12px;
  background: var(--bg);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
  user-select: none;
  white-space: nowrap;
}
.data-table td { padding: 9px 12px; border-bottom: 1px solid var(--border-light); font-size: 13px; }
.data-table tr:hover td { background: #FAFBFC; }
.data-table tr:last-child td { border-bottom: none; }
.log-version-item:hover { background: var(--bg); }
.table-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-light);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.1s var(--ease-out);
  background: var(--card);
  color: var(--text);
  line-height: 1.4;
}
.btn:hover { background: var(--bg); border-color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); opacity: 1; }
.btn-sm { padding: 5px 10px; font-size: 11px; border-radius: 5px; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #FEF2F2; }
.btn-success { color: var(--success); border-color: var(--success); }
.btn-ghost { border: none; background: none; padding: 4px 8px; }

/* ---------- TAGS / BADGES ---------- */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}
.tag-green { background: #ECFDF5; color: #059669; }
.tag-yellow { background: #FFFBEB; color: #D97706; }
.tag-red { background: #FEF2F2; color: #DC2626; }
.tag-gray { background: #F3F4F6; color: #6B7280; }
.tag-blue { background: #EFF6FF; color: #2563EB; }
.tag-orange { background: #FFF7ED; color: #EA580C; }
.tag-purple { background: #F5F3FF; color: #7C3AED; }

/* Rich text editor */
.editor-btn {
  width: 24px; height: 24px; border: none; background: transparent;
  border-radius: 4px; cursor: pointer; font-size: 12px;
  color: var(--text-secondary); display: flex; align-items: center; justify-content: center;
}
.editor-btn:hover { background: #E5E7EB; color: var(--text); }
[contenteditable]:empty:before {
  content: attr(data-placeholder);
  color: #9CA3AF;
}
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }

/* ---------- TOGGLE SWITCH ---------- */
.toggle-switch {
  position: relative;
  width: 40px; height: 22px;
  display: inline-block;
  flex-shrink: 0;
}
.toggle-switch input { display: none; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 11px;
  cursor: pointer;
  transition: 0.2s;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 2px; top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::after { transform: translateX(18px); }

/* ---------- ROBOT TAB IN MODAL ---------- */
#robotConfigModal .tab-bar { display: flex; gap: 4px; border-bottom: 2px solid var(--border-light); }
#robotConfigModal .tab-item {
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
#robotConfigModal .tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
#robotConfigModal .tab-item:hover { color: var(--primary); }

/* ---------- ROBOT PAGE ---------- */
.robot-tab-panel { animation: fadeIn 0.2s ease; }

/* Range slider styling */
input[type="range"] {
  -webkit-appearance: none;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.status-dot.online { background: var(--online); box-shadow: 0 0 0 3px rgba(16,185,129,0.2); }
.status-dot.offline { background: var(--offline); }

/* ---------- SEARCH ---------- */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg);
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: all 0.2s;
  width: 240px;
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,110,247,0.1); }
.search-box input {
  border: none; outline: none; background: transparent;
  font-size: 13px; flex: 1; color: var(--text);
}
.search-box input::placeholder { color: var(--text-muted); }

/* ---------- CHANNEL CARD ---------- */
.channel-card {
  background: var(--card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.channel-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.channel-card .ch-name { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.channel-card .ch-stats { display: flex; gap: 20px; font-size: 12px; color: var(--text-secondary); }

/* ---------- FILE GRID ---------- */
.file-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.file-card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
}
.file-card:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.file-card .file-icon { font-size: 32px; margin-bottom: 8px; }
.file-card .file-name { font-size: 12px; font-weight: 500; margin-bottom: 4px; word-break: break-all; }
.file-card .file-date { font-size: 11px; color: var(--text-muted); }
.file-card .file-actions { display: none; gap: 8px; margin-top: 8px; justify-content: center; }
.file-card:hover .file-actions { display: flex; }

/* ---------- TABS ---------- */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab-item {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  user-select: none;
}
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Sub-tabs (smaller, inside panels) */
.sub-tab-bar {
  display: flex; gap: 4px; margin-bottom: 14px;
}
.sub-tab-item {
  padding: 6px 14px; font-size: 12px; font-weight: 500; cursor: pointer;
  color: var(--text-secondary); border-radius: 6px;
  transition: all 0.15s; user-select: none;
  background: var(--bg);
}
.sub-tab-item:hover { color: var(--text); background: var(--border-light); }
.sub-tab-item.active { color: #fff; background: var(--primary); }

/* ---------- ANNOTATION SYSTEM ---------- */
.annotation {
  position: relative;
  display: none;
}
.annotation.notes-on {
  display: block;
}
.annotation.notes-on::after {
  content: '';
  position: absolute;
  inset: -3px;
  border: 2px dashed var(--primary);
  border-radius: inherit;
  opacity: 0.6;
  pointer-events: none;
  z-index: 1;
}
.note-tooltip {
  display: none;
  position: absolute;
  z-index: 100;
  background: #fff;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  min-width: 200px;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  line-height: 1.5;
}
.notes-on .note-tooltip { display: block; }
.note-tooltip .note-type {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 6px;
}
.note-type.interaction { background: #EFF6FF; color: #2563EB; }
.note-type.logic { background: #FFF7ED; color: #EA580C; }
.note-type.page-desc { background: #F0FDF4; color: #059669; }
.note-tooltip .note-title { font-weight: 700; margin-bottom: 4px; }
.note-tooltip .note-body { color: var(--text-secondary); }

/* Page description banner */
.page-desc-banner {
  display: none;
  background: linear-gradient(135deg, #EFF6FF, #F0FDF4);
  border: 1px solid #BFDBFE;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.notes-on .page-desc-banner { display: none; }
.page-desc-banner .desc-title { font-weight: 700; color: var(--text); margin-bottom: 4px; }

/* ---------- CHAT PAGE ---------- */
.chat-layout {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  height: calc(100vh - var(--topbar-h) - 80px);
  gap: 0;
}
.chat-sidebar {
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}
.chat-sidebar-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
}
.chat-list { flex: 1; overflow-y: auto; }
.chat-list-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.chat-list-item:hover { background: var(--bg); }
.chat-list-item.active { background: var(--primary-light); border-left-color: var(--primary); }
.chat-list-item .cli-name { font-size: 13px; font-weight: 600; }
.chat-list-item .cli-preview { font-size: 11px; color: var(--text-muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list-item .cli-time { font-size: 10px; color: var(--text-muted); margin-top: 2px; float: right; }
.chat-main {
  background: var(--card);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.chat-main-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #FAFBFC;
}
.chat-msg {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  position: relative;
}
.chat-msg.agent {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--border-light);
  border-bottom-left-radius: 4px;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg .msg-time { font-size: 10px; opacity: 0.5; margin-top: 4px; }
.chat-msg.agent .msg-source {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; color: var(--primary); margin-top: 4px;
  background: var(--primary-light); padding: 2px 6px; border-radius: 4px;
  cursor: pointer;
}
/* ---------- MESSAGE ACTION TOOLBAR ---------- */
.msg-actions {
  display: none;
  gap: 2px;
  position: absolute;
  top: -32px;
  z-index: 10;
}
.chat-msg:hover .msg-actions { display: flex; }
.chat-msg.agent .msg-actions { left: 0; }
.chat-msg.user .msg-actions { right: 0; }
.msg-actions .act-btn {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all 0.15s;
  user-select: none;
}
.msg-actions .act-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.msg-actions .act-btn.danger:hover { background: #FEF2F2; color: #DC2626; border-color: #DC2626; }

/* Quote reply preview */
.quote-bar {
  display: none;
  padding: 8px 16px;
  background: var(--primary-light);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  align-items: center;
  gap: 8px;
}
.quote-bar.show { display: flex; }
.quote-bar .quote-text {
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 4px 10px;
  background: #fff;
  border-radius: 4px;
  border-left: 3px solid var(--primary);
}
.quote-bar .quote-close {
  cursor: pointer; color: var(--text-muted); font-size: 14px; padding: 2px 6px;
}
.quote-bar .quote-close:hover { color: #EF4444; }

/* Retracted message */
.chat-msg.retracted {
  opacity: 0.5;
  font-style: italic;
  pointer-events: none;
}

/* Translated overlay */
.msg-translated {
  display: block; margin-top: 6px; padding: 6px 8px;
  background: rgba(0,0,0,0.03); border-radius: 6px;
  font-size: 11px; color: var(--text-muted); border: 1px dashed var(--border);
}

.chat-warning {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  padding: 8px 14px;
  font-size: 12px;
  color: #92400E;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-input-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-input-bar input {
  flex: 1; border: 1px solid var(--border); border-radius: 20px;
  padding: 8px 14px; font-size: 13px; outline: none;
}
.chat-input-bar input:focus { border-color: var(--primary); }
.chat-info-panel {
  background: var(--card);
  padding: 16px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.chat-info-panel .info-group h4 {
  font-size: 11px; text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 8px; letter-spacing: 0.5px;
}
.chat-info-panel .info-row {
  display: flex; justify-content: space-between;
  font-size: 13px; padding: 4px 0;
}
.chat-info-panel .info-row .label { color: var(--text-secondary); }

/* ---------- UPLOAD ZONE ---------- */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--card);
  margin-top: 16px;
}
.upload-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-zone .upload-icon { font-size: 28px; margin-bottom: 8px; }
.upload-zone .upload-text { font-size: 13px; color: var(--text-secondary); }
.upload-modes { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.upload-mode {
  padding: 4px 12px; border-radius: 14px; font-size: 11px;
  border: 1px solid var(--border); cursor: pointer;
}
.upload-mode.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- TICKET PAGE ---------- */
.ticket-filter-bar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.ticket-filter-bar select, .ticket-filter-bar input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; outline: none; background: var(--card); color: var(--text); height: 34px; }
.ticket-filter-bar select:focus, .ticket-filter-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,110,247,0.1); }
.ticket-filter-bar input[type="date"] { padding: 6px 10px; height: 34px; }
.ticket-priority { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.ticket-priority.high { background: #EF4444; }
.ticket-priority.normal { background: #F59E0B; }
.ticket-status-tag { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 500; }
.ts-new { background: #EFF6FF; color: #2563EB; }
.ts-waiting { background: #FEF3C7; color: #D97706; }
.ts-processing { background: #EDE9FE; color: #7C3AED; }
.ts-confirming { background: #D1FAE5; color: #059669; }
.ts-done { background: #D1FAE5; color: #059669; }
.ts-closed { background: #F1F5F9; color: #64748B; }
.ts-overtime { background: #FEE2E2; color: #DC2626; font-weight: 600; }
.ticket-row-overtime { background: #FFF5F5 !important; border-left: 3px solid #EF4444 !important; }
.ticket-row-overtime:hover td { background: #FEE2E2 !important; }

/* ---------- CRM PAGE ---------- */
.crm-layout { display: grid; grid-template-columns: 1fr 380px; gap: 14px; }
.crm-detail-panel { background: var(--card); border-radius: var(--radius-md); padding: 16px; box-shadow: var(--shadow-sm); }
.crm-detail-panel h3 { font-size: 15px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-light); }
.crm-info-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.crm-info-row .label { color: var(--text-secondary); }
.crm-tag-list { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0; }
.crm-tag-item { display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px; border-radius: 12px; font-size: 11px; background: var(--bg); cursor: pointer; }
.crm-tag-item:hover { background: var(--primary-light); }
.crm-tag-item .remove-tag { cursor: pointer; color: var(--text-muted); font-size: 12px; margin-left: 2px; }
.crm-tag-item .remove-tag:hover { color: var(--danger); }
.crm-section { margin-top: 14px; }
.crm-section h4 { font-size: 12px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 8px; letter-spacing: 0.5px; }
.crm-history-item { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg); margin-bottom: 4px; font-size: 12px; cursor: pointer; }
.crm-history-item:hover { background: var(--primary-light); }

/* ---------- DASHBOARD ---------- */
.dashboard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.dashboard-chart { background: var(--card); border-radius: var(--radius-md); padding: 16px; box-shadow: var(--shadow-xs); border: 1px solid var(--border-light); }
.dashboard-chart h4 { font-size: 12px; margin-bottom: 12px; color: var(--text-muted); }
.chart-placeholder { display: flex; align-items: center; justify-content: center; height: 150px; color: var(--text-muted); font-size: 13px; background: var(--bg); border-radius: var(--radius-sm); }
.dash-card-highlight { border-left: 4px solid var(--primary); }

/* ---------- KB & SCRIPT PANEL ---------- */
.kb-content-panel { display: none; }
.kb-content-panel.active { display: block; }
/* Shared toolbar used by both KB and AI training */
.panel-toolbar {
  display: flex; gap: 12px; margin-bottom: 16px; align-items: center; justify-content: space-between;
}
.panel-toolbar .search-box { flex: 1; max-width: 360px; }

/* ---------- AI TRAINING FORM ---------- */
.training-form-panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 16px 20px; box-shadow: var(--shadow-sm);
}
.training-form-panel .form-row {
  display: flex; gap: 10px; margin-bottom: 10px; align-items: flex-start;
}
.training-form-panel .form-row:last-child { margin-bottom: 0; }
.training-form-panel input, .training-form-panel textarea, .training-form-panel select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; outline: none; flex: 1;
}
.training-form-panel input:focus, .training-form-panel textarea:focus, .training-form-panel select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light);
}
.training-form-panel textarea { min-height: 52px; resize: vertical; flex: 2; }
.training-form-panel .form-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.approval-tag {
  display: inline-block; padding: 2px 10px; border-radius: 10px;
  font-size: 11px; font-weight: 500;
}
.apv-pending { background: #FEF3C7; color: #D97706; }
.apv-approved { background: #D1FAE5; color: #059669; }
.apv-rejected { background: #FEE2E2; color: #DC2626; }
.apv-direct { background: #EFF6FF; color: #2563EB; }

/* ---------- SCRIPT OPTIONS (多方案选择) ---------- */
.script-options { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.script-option-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 14px; transition: all 0.2s; position: relative;
}
.script-option-card:hover { box-shadow: var(--shadow-sm); }
.script-option-card.selected { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 0 0 1px var(--primary); }
.script-option-card.recommended { border-color: #BFDBFE; }
.script-recommend-badge {
  position: absolute; top: -8px; left: 12px;
  background: var(--primary); color: #fff; font-size: 10px;
  padding: 2px 8px; border-radius: 8px; font-weight: 600;
}
.script-option-header { font-weight: 600; font-size: 13px; margin-bottom: 6px; margin-top: 2px; }
.script-option-body { font-size: 12px; line-height: 1.7; color: var(--text-secondary); }
.script-option-action { margin-top: 8px; display: flex; gap: 8px; justify-content: flex-end; }
.script-none-correct { margin-top: 8px; text-align: right; padding-right: 4px; }
.script-quick-fix {
  margin-top: 10px; padding: 12px; background: #FFFBEB; border: 1px solid #FCD34D;
  border-radius: var(--radius-md);
}
.script-quick-fix .form-row { display: flex; gap: 8px; align-items: flex-start; }
.script-quick-fix .form-actions { display: flex; gap: 8px; justify-content: flex-end; }
.script-quick-fix input, .script-quick-fix textarea, .script-quick-fix select {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12px; font-family: inherit; outline: none;
}
.script-quick-fix input:focus, .script-quick-fix textarea:focus, .script-quick-fix select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light);
}

/* ---------- MODAL ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  justify-content: center;
  align-items: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 440px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
}
.modal h3 { margin-bottom: 16px; }
.modal .form-group { margin-bottom: 14px; }
.modal .form-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--text-secondary); }
.modal .form-group input, .modal .form-group select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; outline: none;
}
.modal .form-group input:focus, .modal .form-group select:focus { border-color: var(--primary); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  z-index: 300;
  transform: translateX(120%);
  transition: transform 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.show { transform: translateX(0); }
.toast.success { border-left: 3px solid var(--success); }

/* ---------- TRANSITIONS ---------- */
.fade-in { animation: fadeIn 0.25s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive */
@media (max-width: 1024px) {
  .chat-layout { grid-template-columns: 200px 1fr 240px; }
  .file-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- ANNOTATION PANEL (右侧注释列) ---------- */
.annotation-panel {
  width: 0;
  background: var(--card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.25s ease;
  z-index: 5;
}
.annotation-panel.expanded { width: 310px; }
.annotation-panel-header {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  white-space: nowrap;
}
.annotation-panel-header .ap-close {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border-radius: 4px;
  font-size: 14px; color: var(--text-muted);
  transition: all 0.15s;
}
.annotation-panel-header .ap-close:hover { background: var(--bg); color: var(--text); }
.annotation-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.annotation-panel-body .ap-section {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  border-left: 3px solid var(--primary);
}
.annotation-panel-body .ap-section.logic { border-left-color: #EA580C; }
.annotation-panel-body .ap-section.ac { border-left-color: #10B981; }
.annotation-panel-body .ap-section.error { border-left-color: #EF4444; }
.annotation-panel-body .ap-section .ap-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; margin-bottom: 6px;
}
.annotation-panel-body .ap-section.interaction .ap-label { color: #2563EB; }
.annotation-panel-body .ap-section.logic .ap-label { color: #EA580C; }
.annotation-panel-body .ap-section.ac .ap-label { color: #059669; }
.annotation-panel-body .ap-section.error .ap-label { color: #DC2626; }
.annotation-panel-body .ap-item {
  font-size: 11px; line-height: 1.5; color: var(--text-secondary);
  margin-bottom: 6px; padding-left: 8px; border-left: 1px solid var(--border);
}
.annotation-panel-body .ap-item:last-child { margin-bottom: 0; }
.annotation-panel-body .ap-item strong { color: var(--text); }

/* Annotation toggle button on toolbar */
.ap-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 20px;
  border: 1px solid var(--border);
  cursor: pointer; font-size: 12px;
  color: var(--text-secondary); background: var(--card);
  transition: all 0.2s; user-select: none;
}
.ap-toggle:hover { border-color: var(--primary); color: var(--primary); }
.ap-toggle.active { background: #FFF7ED; color: #EA580C; border-color: #EA580C; }

/* ---------- QUICK REPLY & AI SUGGEST PANELS ---------- */
.quick-reply-panel, .ai-suggest-panel {
  border-top: 1px solid var(--border);
  background: var(--card);
  max-height: 180px;
  overflow-y: auto;
}
.grp-header {
  padding: 8px 16px;
  font-size: 12px; font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  border-bottom: 1px solid var(--border-light);
}
.grp-item {
  padding: 8px 16px;
  font-size: 12px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer; transition: all 0.15s;
}
.grp-item:hover { background: var(--bg); color: var(--text); }
.grp-item:last-child { border-bottom: none; }

/* Filter tag active */
.filter-tag.active { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ---------- TAKEOVER UI (NEW: chat-header + input bar) ---------- */
/* Chat header right group: AI status + end-session button */
.chat-header-right { display: flex; align-items: center; gap: 8px; margin-left: auto; margin-right: 12px; }
.header-ai-status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.ai-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ai-status-dot.on { background: #10B981; box-shadow: 0 0 4px rgba(16,185,129,0.5); }
.ai-status-dot.off { background: #F59E0B; box-shadow: 0 0 4px rgba(245,158,11,0.5); }
.header-ai-status.on { background: #ECFDF5; color: #059669; }
.header-ai-status.off { background: #FEF3C7; color: #D97706; }
.header-end-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: #059669;
  color: #fff;
  white-space: nowrap;
  transition: all 0.15s;
}
.header-end-btn:hover { background: #047857; }

/* Chat input takeover state */
.chat-input-takeover {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 8px 16px; flex: 1;
}
.chat-input-takeover .takeover-hint {
  font-size: 13px; color: var(--text-muted);
  display: flex; align-items: center; gap: 4px;
}
.takeover-input-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: #D97706;
  color: #fff;
  white-space: nowrap;
  transition: all 0.15s;
}
.takeover-input-btn:hover { background: #B45309; }

/* Chat input actions (normal mode) */
.chat-input-actions { display: flex; align-items: center; gap: 8px; flex: 1; }

/* ---------- AI ASSISTANT PAGE ---------- */
.assistant-layout {
  display: grid;
  grid-template-columns: 240px 1fr 300px;
  height: calc(100vh - var(--topbar-h) - 80px);
  gap: 0;
}
.assistant-sidebar {
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}
.assistant-sidebar-header {
  padding: 14px;
  border-bottom: 1px solid var(--border-light);
  font-weight: 700;
  font-size: 14px;
}
.assistant-scenarios { flex: 1; overflow-y: auto; padding: 8px; }
.as-scenario {
  padding: 12px;
  margin: 4px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.as-scenario:hover { background: var(--bg); }
.as-scenario.active {
  background: var(--primary-light);
  border-color: var(--primary);
}
.as-scenario .as-icon { font-size: 24px; margin-bottom: 6px; }
.as-scenario .as-name { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.as-scenario .as-desc { font-size: 11px; color: var(--text-muted); }
.assistant-main {
  background: var(--card);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.assistant-main-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #F5F3FF, #EDE9FE);
}
.assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #FAFBFC;
}
.assistant-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
}
.assistant-msg.employee {
  align-self: flex-end;
  background: #F5F3FF;
  border: 1px solid #DDD6FE;
  border-bottom-right-radius: 4px;
  color: var(--text);
}
.assistant-msg.ai {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--border-light);
  border-bottom-left-radius: 4px;
}
.assistant-msg.ai .as-source {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; color: #7C3AED; margin-top: 4px;
  background: #F5F3FF; padding: 2px 6px; border-radius: 4px;
  cursor: pointer;
}
.assistant-quote-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 12px;
}
.assistant-quote-card .aq-header {
  font-weight: 600; color: var(--primary);
  margin-bottom: 6px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}
.assistant-quote-card .aq-row {
  display: flex; justify-content: space-between;
  padding: 3px 0; font-size: 11px;
}
.assistant-quote-card .aq-total {
  font-weight: 700; color: var(--primary);
  font-size: 14px; text-align: right;
  margin-top: 6px; padding-top: 6px;
  border-top: 1px solid var(--border-light);
}
.assistant-input-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.assistant-input-bar textarea {
  flex: 1; border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 14px; font-size: 13px; outline: none;
  resize: none; height: 40px; font-family: inherit;
}
.assistant-input-bar textarea:focus { border-color: #7C3AED; }
.assistant-info-panel {
  background: var(--card);
  padding: 16px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.as-info-group h4 {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}
/* Assistant page flex layout */
#page-assistant.active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);
  overflow: hidden;
}
/* Error correction */
.correction-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid var(--warning);
}
.correction-item:hover { background: #FEF3C7; }
.correction-item .ci-meta { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.correction-item .ci-status {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  margin-top: 4px;
}
.ci-status.pending { background: #FEF3C7; color: #D97706; }
.ci-status.applied { background: #D1FAE5; color: #059669; }
.ci-status.reviewed { background: #DBEAFE; color: #2563EB; }
.correction-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: #FEF3C7; color: #D97706;
  padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.correction-badge:hover { background: #FDE68A; }

/* Assistant scenario quick-actions */
.as-quick-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg);
}
.as-quick-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 11px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-secondary);
  transition: all 0.15s;
  white-space: nowrap;
}
.as-quick-btn:hover { border-color: #7C3AED; color: #7C3AED; background: #F5F3FF; }

/* Logistics tracking inline input */
.tracking-agent {
  display: inline-flex; align-items: center; gap: 6px;
  background: #F5F3FF; border: 1px solid #DDD6FE; border-radius: 8px;
  padding: 4px 8px; margin-top: 6px;
}
.tracking-agent input {
  width: 160px; padding: 4px 8px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 12px; outline: none; font-family: monospace;
}
.tracking-agent input:focus { border-color: #7C3AED; box-shadow: 0 0 0 2px #EDE9FE; }
.tracking-agent button {
  padding: 4px 12px; background: #7C3AED; color: #fff; border: none;
  border-radius: 6px; font-size: 11px; cursor: pointer; font-weight: 500;
}
.tracking-agent button:hover { background: #6D28D9; }

/* ---------- AI ASSISTANT FLOATING OVERLAY (in knowledge base) ---------- */
.ai-chat-overlay-mask {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}
.ai-chat-overlay-mask.show { display: flex; }
.ai-chat-overlay {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 80vw;
  height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ai-chat-overlay-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #F5F3FF, #EDE9FE);
  border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}
.ai-chat-overlay-body {
  flex: 1;
  display: grid;
  grid-template-columns: 200px 1fr 260px;
  overflow: hidden;
}
.ai-chat-overlay-body .assistant-sidebar { border-radius: 0; }
.ai-chat-overlay-body .assistant-main { border-radius: 0; }
.ai-chat-overlay-body .assistant-info-panel { border-radius: 0; }
.ai-chat-overlay-close {
  margin-left: auto;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-muted);
  padding: 0 4px;
  border-radius: 4px;
  transition: all 0.15s;
}
.ai-chat-overlay-close:hover { color: var(--danger); background: #FEE2E2; }

/* Floating trigger button */
.kb-ai-trigger {
  position: fixed;
  bottom: 28px;
  right: 40px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7C3AED, #6D28D9);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(124,58,237,0.4);
  z-index: 999;
  transition: all 0.2s;
  border: none;
  font-size: 24px;
}
.kb-ai-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 22px rgba(124,58,237,0.5);
}
.kb-ai-trigger .trigger-tooltip {
  position: absolute;
  right: 64px;
  background: var(--text);
  color: #fff;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.kb-ai-trigger:hover .trigger-tooltip { opacity: 1; }

/* Inline SVG vector icons */
.ico {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.15em;
  flex-shrink: 0;
}
.ico-sm {
  width: 0.85em;
  height: 0.85em;
  vertical-align: -0.1em;
}
.ico-lg {
  width: 1.5em;
  height: 1.5em;
  vertical-align: -0.3em;
}

/* ====== Order Detail Drawer ====== */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.3);
  display: none; opacity: 0;
  transition: opacity 0.25s ease;
}
.drawer-overlay.show { display: block; opacity: 1; }
.drawer-panel {
  position: fixed; top: 0; right: -760px; bottom: 0;
  width: 760px; z-index: 1001;
  background: var(--card);
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  transition: right 0.3s ease;
  display: flex; flex-direction: column;
}
.drawer-overlay.show .drawer-panel { right: 0; }
.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.drawer-header h3 { margin: 0; font-size: 15px; }
.drawer-close {
  width: 28px; height: 28px; border: none; background: transparent;
  cursor: pointer; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.drawer-close:hover { background: var(--bg); color: var(--text); }
.drawer-body {
  flex: 1; overflow-y: auto; padding: 16px;
  display: grid; grid-template-columns: 200px 1fr; gap: 16px;
}
.drawer-tree-module {
  padding: 8px 10px; border-radius: 6px; margin-bottom: 4px; font-size: 11px;
  border: 1px solid var(--border); cursor: default;
}
.drawer-tree-module.done { background: #ECFDF5; border-color: #A7F3D0; color: #065F46; }
.drawer-tree-module.active { background: #EFF6FF; border-color: #93C5FD; color: #1E40AF; }
.drawer-tree-module.pending { background: #F9FAFB; border-color: var(--border); color: #9CA3AF; }
.drawer-tree-module.error { background: #FEF2F2; border-color: #FCA5A5; color: #991B1B; }
.drawer-tree-icon { width:14px;height:14px;margin-right:4px;vertical-align:-2px; }
.drawer-field { margin-bottom: 14px; }
.drawer-field-label { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.drawer-field-value { font-size: 13px; color: var(--text); font-weight: 500; }
.drawer-section-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.drawer-demand {
  font-size: 13px; line-height: 1.7; color: var(--text);
  max-height: calc(100vh - 160px); overflow-y: auto;
}
.drawer-demand:empty:after { content: '暂无客户要求'; color: var(--text-muted); }

.drawer-info-row {
  display: flex; align-items: center; padding: 6px 0; font-size: 12px;
}
.drawer-info-label {
  color: var(--text-muted); width: 72px; flex-shrink: 0; font-weight: 500;
}
.drawer-info-value {
  color: var(--text); font-weight: 500;
}

/* Urgent row */
tr.urgent-row { background: #FEF2F2 !important; }
tr.urgent-row:hover { background: #FEE2E2 !important; }
tr.urgent-row td:first-child { position: relative; padding-left: 28px !important; }
tr.urgent-row td:first-child:before {
  content: ''; position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; border-radius: 50%;
  background: #DC2626;
  box-shadow: 0 0 0 3px rgba(220,38,38,0.2);
}

/* Order management: 6-col stat cards */
#orderPkgStats.stat-cards { display:flex; flex-wrap:nowrap; gap:8px; overflow-x:auto; }
#orderPkgStats.stat-cards .stat-card { flex:1 0 auto; min-width:72px; padding:8px 6px; }
#orderPkgStats.stat-cards .stat-card .stat-label { font-size:10px; margin-bottom:2px; white-space:nowrap; }
#orderPkgStats.stat-cards .stat-card .stat-value { font-size:20px; }
#orderPkgStats.stat-cards .stat-card .ico-lg { width:18px; height:18px; }
#orderPickStats.stat-cards { grid-template-columns: repeat(5, 1fr); }
#orderPackStats.stat-cards { grid-template-columns: repeat(8, 1fr); gap:4px; }
#orderPackStats.stat-cards .stat-card { padding:8px 4px; gap:6px; min-width:0; }
#orderPackStats.stat-cards .stat-card-icon { width:24px; height:24px; }
#orderPackStats.stat-cards .stat-card-body .stat-value { font-size:16px; }
#orderPackStats.stat-cards .stat-card-body .stat-label { font-size:10px; }
#orderExStats.stat-cards { grid-template-columns: repeat(3, 1fr); }
#orderVerifyStats.stat-cards { grid-template-columns: repeat(5, 1fr); }
#orderVerifyStats.stat-cards .stat-card { padding:8px 4px; gap:6px; min-width:0; }
#orderVerifyStats.stat-cards .stat-card-icon { width:24px; height:24px; }
#orderVerifyStats.stat-cards .stat-card-body .stat-value { font-size:16px; }
#orderVerifyStats.stat-cards .stat-card-body .stat-label { font-size:10px; }
#orderReturnStats.stat-cards { grid-template-columns: repeat(4, 1fr); }
#orderOverviewStats.stat-cards { display:flex; flex-wrap:nowrap; gap:8px; overflow-x:auto; }
#orderOverviewStats.stat-cards .stat-card { flex:1 0 0; min-width:80px; padding:8px 6px; }
#orderOverviewStats.stat-cards .stat-card .stat-label { font-size:10px; margin-bottom:2px; }
#orderOverviewStats.stat-cards .stat-card .stat-value { font-size:20px; }
#orderOverviewStats.stat-cards .stat-card .ico-lg { width:18px; height:18px; }
#orderOverviewStats.stat-cards .stat-card:nth-child(1) .stat-value { font-size:22px; }
@media (max-width: 1024px) {
  #orderPkgStats.stat-cards .stat-card { min-width:56px; }
}

/* Order management: page container fixes */
[class^="page-"][id^="page-order"] { min-height: 0; }

/* Order management: modal overlay inside main — keep hidden */
main > .modal-overlay { display: none !important; }
main > .modal-overlay.show { display: flex !important; }

/* ====== ORDER OVERVIEW: Pipeline ====== */
.pipeline-bar {
  display: flex;
  align-items: stretch;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--card);
}
.pipeline-stage {
  flex: 1;
  text-align: center;
  padding: 10px 8px 8px;
  cursor: pointer;
  transition: all 0.15s var(--ease-out);
  border-right: 1px solid var(--border);
  position: relative;
}
.pipeline-stage:last-child { border-right: none; }
.pipeline-stage:hover { background: var(--bg); }
.pipeline-stage.active { background: var(--primary-light); }
.pipeline-stage .ps-icon {
  width: 20px; height: 20px;
  margin: 0 auto 4px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
  background: var(--border);
  transition: background 0.2s;
}
.pipeline-stage.active .ps-icon { background: var(--primary); }
.pipeline-stage.done .ps-icon { background: var(--success); }
.pipeline-stage.warn .ps-icon { background: var(--warning, #D97706); }
.pipeline-stage .ps-label {
  font-size: 11px; color: var(--text-muted);
  display: block;
}
.pipeline-stage .ps-count {
  font-size: 18px; font-weight: 700; color: var(--text);
  display: block; line-height: 1.2;
}
.pipeline-stage.active .ps-label { color: var(--primary); font-weight: 600; }
.pipeline-stage.done .ps-count { color: var(--success); }
.pipeline-stage.warn .ps-count { color: var(--warning, #D97706); }

/* Mini progress bar in table */
.mini-flow {
  display: flex; align-items: center; gap: 0;
  height: 22px;
}
.mini-flow-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.2s;
}
.mini-flow-dot.done { background: var(--success); }
.mini-flow-dot.active { background: var(--primary); }
.mini-flow-dot.warn { background: #DC2626; }
.mini-flow-line {
  flex: 1; height: 3px; background: var(--border);
  margin: 0 4px;
  transition: background 0.2s;
}
.mini-flow-line.done { background: var(--success); }
.mini-flow-line.active { background: var(--primary); }

/* Flow node for overview page */
.flow-node { padding:2px 6px; border-radius:4px; background:#F3F4F6; color:#9CA3AF; white-space:nowrap; }
.flow-node.done { background:#ECFDF5; color:#059669; }
.flow-node.active { background:#EFF6FF; color:#2563EB; font-weight:600; }

.order-detail-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}
.order-detail-panel .od-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}
.order-detail-panel .od-label { font-size: 11px; color: var(--text-muted); }
.order-detail-panel .od-value { font-size: 13px; color: var(--text); font-weight: 500; }

@media (max-width: 768px) {
  .mini-flow { transform: scale(0.85); }
  .pipeline-stage { padding: 8px 4px 6px; }
  .pipeline-stage .ps-label { font-size: 10px; }
  .pipeline-stage .ps-count { font-size: 14px; }
}

