/* Ginny CRM - Stylesheet */

:root {
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1e40af;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0891b2;
  --info-light: #cffafe;
  --purple: #9333ea;
  --purple-light: #f3e8ff;

  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --sidebar-w: 240px;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header .logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-header .logo .icon {
  width: 32px; height: 32px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.sidebar-header .subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.nav-section {
  margin-bottom: 8px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.nav-item .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 24px 32px;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }

.btn-secondary { background: var(--surface); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
}

.card-body { padding: 16px 20px; }

/* Dashboard stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
}

.stat-card.blue::before { background: var(--primary); }
.stat-card.green::before { background: var(--success); }
.stat-card.orange::before { background: var(--warning); }
.stat-card.red::before { background: var(--danger); }
.stat-card.purple::before { background: var(--purple); }
.stat-card.cyan::before { background: var(--info); }

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-top: 4px;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stat-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 24px;
  opacity: 0.2;
}

/* Tables */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table tbody tr:hover {
  background: var(--bg);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { color: var(--success); background: var(--success-light); }
.badge-warning { color: #92400e; background: var(--warning-light); }
.badge-danger { color: var(--danger); background: var(--danger-light); }
.badge-info { color: var(--info); background: var(--info-light); }
.badge-default { color: var(--text-secondary); background: var(--bg); }
.badge-purple { color: var(--purple); background: var(--purple-light); }

/* Forms */
.form-group {
  margin-bottom: 16px;
}

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

.form-label .required { color: var(--danger); }

.form-label .hint {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 6px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

select.form-control {
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-box.large { max-width: 800px; }
.modal-box.xlarge { max-width: 1000px; }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  box-shadow: var(--shadow-lg);
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-warning { background: var(--warning); color: white; }
.toast-info { background: var(--info); color: white; }

/* Search bar */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.search-bar input, .search-bar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
}

.search-bar input { flex: 1; min-width: 200px; }
.search-bar input:focus, .search-bar select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.empty-state .title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-state .desc {
  font-size: 13px;
}

/* Customer 360 view */
.customer-360 {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
}

.customer-profile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.customer-profile .avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
}

.customer-profile .name {
  font-size: 18px;
  font-weight: 700;
}

.customer-profile .code {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.customer-profile .info-item {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.customer-profile .info-item:last-child { border-bottom: none; }
.customer-profile .info-label { color: var(--text-muted); min-width: 70px; }
.customer-profile .info-value { color: var(--text); font-weight: 500; }

.customer-tabs {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tab-header {
  display: flex;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab-btn {
  padding: 12px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all var(--transition);
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.tab-content { padding: 16px 20px; }

/* Alert boxes */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.alert-warning { background: var(--warning-light); color: #92400e; border-left: 3px solid var(--warning); }
.alert-danger { background: var(--danger-light); color: #991b1b; border-left: 3px solid var(--danger); }
.alert-info { background: var(--info-light); color: #155e75; border-left: 3px solid var(--info); }
.alert-success { background: var(--success-light); color: #166534; border-left: 3px solid var(--success); }

/* Timeline */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 16px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
}

.timeline-date {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.timeline-content {
  font-size: 13px;
  margin-top: 2px;
}

/* Guard config table */
.guard-config-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.guard-config-table th, .guard-config-table td {
  padding: 6px 8px;
  border: 1px solid var(--border);
}

.guard-config-table th {
  background: var(--bg);
  font-size: 12px;
  font-weight: 600;
}

.guard-config-table input {
  width: 100%;
  border: none;
  padding: 4px 6px;
  font-size: 13px;
  background: transparent;
}

.guard-config-table input:focus {
  outline: 1px solid var(--primary);
  border-radius: 3px;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
  .customer-360 { grid-template-columns: 1fr; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
}

/* Utility */
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.cursor-pointer { cursor: pointer; }

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 101;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 18px;
}

@media (max-width: 768px) {
  .menu-toggle { display: block; }
  .main-content { padding-top: 56px; }
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  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); }
}

.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.loading-overlay .spinner {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

/* ===== Daily Assistant ===== */
.assistant-modal { max-width: 720px; }
.assistant-greeting { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.assistant-date { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }

.assistant-overview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.assistant-overview-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  border: 1px solid var(--border);
}

.assistant-overview-item .count { font-size: 24px; font-weight: 700; color: var(--text); }
.assistant-overview-item .label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.assistant-overview-item.alert .count { color: var(--danger); }
.assistant-overview-item.warning .count { color: var(--warning); }

.wizard-steps { display: flex; gap: 4px; margin-bottom: 20px; }
.wizard-step-indicator { flex: 1; height: 4px; border-radius: 2px; background: var(--border); transition: background var(--transition); }
.wizard-step-indicator.active { background: var(--primary); }
.wizard-step-indicator.done { background: var(--success); }

.wizard-question { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.wizard-hint { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }

.select-list { max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.select-list-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background var(--transition); }
.select-list-item:hover { background: var(--bg); }
.select-list-item:last-child { border-bottom: none; }
.select-list-item.selected { background: var(--primary-light); }
.select-list-item input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

/* Todo list */
.todo-list { list-style: none; padding: 0; margin: 0; }
.todo-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); transition: background var(--transition); }
.todo-item:hover { background: var(--bg); }
.todo-item:last-child { border-bottom: none; }
.todo-checkbox { width: 20px; height: 20px; margin-top: 1px; cursor: pointer; accent-color: var(--primary); flex-shrink: 0; }
.todo-text { flex: 1; font-size: 13px; line-height: 1.5; }
.todo-item.done .todo-text { text-decoration: line-through; color: var(--text-muted); }
.todo-category { font-size: 11px; padding: 2px 6px; border-radius: 3px; font-weight: 600; white-space: nowrap; }
.todo-cat-visit { color: var(--purple); background: var(--purple-light); }
.todo-cat-billing { color: #92400e; background: var(--warning-light); }
.todo-cat-complaint { color: var(--danger); background: var(--danger-light); }
.todo-cat-message { color: var(--info); background: var(--info-light); }
.todo-cat-other { color: var(--text-secondary); background: var(--bg); }

/* Message templates */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.template-card { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; text-align: center; transition: all var(--transition); }
.template-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.template-card.active { border-color: var(--primary); background: var(--primary-light); }
.template-card .icon { font-size: 28px; margin-bottom: 8px; }
.template-card .name { font-size: 13px; font-weight: 600; }
.template-card .desc { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.message-output { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; font-size: 13px; line-height: 1.8; white-space: pre-wrap; max-height: 400px; overflow-y: auto; }

/* Risk badges */
.risk-high { color: var(--danger); background: var(--danger-light); }
.risk-medium { color: #92400e; background: var(--warning-light); }
.risk-low { color: var(--success); background: var(--success-light); }

/* Progress bar */
.progress-bar { width: 100%; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.3s ease; }

/* Quick actions */
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-action { display: flex; align-items: center; gap: 6px; padding: 8px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-secondary); transition: all var(--transition); }
.quick-action:hover { background: var(--primary); color: white; border-color: var(--primary); }
.quick-action .icon { font-size: 16px; }

/* Mini stats */
.stats-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-mini { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.stat-mini .value { font-size: 22px; font-weight: 700; }
.stat-mini .label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* AR table risk */
.ar-overdue { color: var(--danger); font-weight: 600; }
.ar-warning { color: #92400e; font-weight: 600; }
.ar-normal { color: var(--success); }

/* Close rate circle */
.close-rate-circle { width: 80px; height: 80px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; border: 4px solid; }

/* Responsive */
@media (max-width: 768px) {
  .assistant-overview { grid-template-columns: repeat(2, 1fr); }
  .template-grid { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   CustomerPicker - 客户选择器 (可搜索/可新增)
   ============================================================ */
.customer-picker {
  position: relative;
  width: 100%;
}

.cp-input-wrap {
  position: relative;
}

.cp-input-wrap .cp-search {
  padding-right: 32px;
}

.cp-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 6px;
  border-radius: 4px;
}

.cp-clear:hover {
  background: var(--bg);
  color: var(--danger);
}

.cp-selected-tag {
  padding: 8px 12px;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: 6px;
  margin-top: 4px;
}

.cp-tag-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.cp-tag-code {
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.cp-tag-name {
  color: var(--text-primary);
  font-weight: 500;
  flex: 1;
}

.cp-tag-remove {
  background: transparent;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--primary);
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
}

.cp-tag-remove:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--danger);
}

.cp-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  margin-top: 4px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  max-height: 360px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cp-results {
  flex: 1;
  overflow-y: auto;
  max-height: 300px;
}

.cp-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

.cp-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

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

.cp-item:hover,
.cp-item.is-active {
  background: var(--primary-light);
}

.cp-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.cp-item-code {
  background: var(--bg);
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-family: 'SF Mono', Monaco, monospace;
  font-weight: 600;
}

.cp-item-name {
  color: var(--text-primary);
  font-weight: 500;
}

.cp-item-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-secondary);
  padding-left: 4px;
}

.cp-status {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
}

.cp-status-Active,
.cp-status-ACTIVE {
  background: var(--success-light);
  color: var(--success);
}

.cp-status-Expired,
.cp-status-EXPIRED,
.cp-status-Inactive {
  background: var(--warning-light);
  color: var(--warning);
}

.cp-create-new {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  background: var(--success-light);
  color: var(--success);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.12s;
}

.cp-create-new:hover {
  background: var(--success);
  color: white;
}

.cp-create-new span {
  font-weight: 600;
}

/* ===== v2 增强样式 ===== */

/* 销售漏斗柱状图动画 */
.stat-grid .stat-card { transition: transform 0.15s; }
.stat-grid .stat-card:hover { transform: translateY(-2px); }

/* 安保事件处置流程步骤条 */
.incident-flow { display:flex; align-items:center; gap:6px; padding:4px 0; }
.incident-flow-dot { width:10px; height:10px; border-radius:50%; transition: all 0.2s; }
.incident-flow-dot.active { box-shadow: 0 0 0 3px rgba(37,99,235,0.2); }

/* 严重度 P0-P3 徽章 */
.badge-p0 { background:#fef2f2 !important; color:#dc2626 !important; font-weight:700; }
.badge-p1 { background:#fff7ed !important; color:#ea580c !important; }
.badge-p2 { background:#fffbeb !important; color:#d97706 !important; }
.badge-p3 { background:#f7fee7 !important; color:#65a30d !important; }

/* 客户分级徽章 */
.tier-a { background:#fef2f2; color:#dc2626; font-weight:600; padding:2px 8px; border-radius:4px; font-size:12px; }
.tier-b { background:#fffbeb; color:#d97706; font-weight:600; padding:2px 8px; border-radius:4px; font-size:12px; }
.tier-c { background:#eff6ff; color:#2563eb; font-weight:600; padding:2px 8px; border-radius:4px; font-size:12px; }

/* 销售中心业务线卡片 */
.sales-line-card { border:1px solid var(--border); border-radius:12px; padding:16px; background:var(--surface); transition: box-shadow 0.15s; }
.sales-line-card:hover { box-shadow: var(--shadow-md); }

/* 账单催收按钮 */
.btn-collection { background:linear-gradient(135deg,#f59e0b,#d97706); color:#fff; border:none; }
.btn-collection:hover { background:linear-gradient(135deg,#d97706,#b45309); }

/* 活动日志新类型 */
.type-contractChange { background:#f3e8ff; color:#7c3aed; }
.type-collection { background:#fff7ed; color:#ea580c; }

/* 表格行逾期高亮 */
tr.row-overdue { background:#fff7f7 !important; }
tr.row-overdue:hover { background:#fef2f2 !important; }

/* 响应式：移动端漏斗图 */
@media (max-width:768px) {
  .sales-funnel-container { flex-direction:column; height:auto !important; gap:8px; }
  .sales-funnel-container > div { width:100% !important; max-width:none !important; }
}

/* ============================================================
   管理层视角组件 (Management View Components)
   ============================================================ */

/* 管理层摘要块 */
.mgmt-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.mgmt-section {
  padding: 14px 18px;
  border-right: 1px solid var(--border);
}

.mgmt-section:last-child {
  border-right: none;
}

.mgmt-section-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.mgmt-results { background: linear-gradient(180deg, rgba(37,99,235,0.03), transparent); }
.mgmt-risks { background: linear-gradient(180deg, rgba(245,158,11,0.03), transparent); }
.mgmt-actions { background: linear-gradient(180deg, rgba(22,163,74,0.03), transparent); }

.mgmt-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mgmt-list li {
  font-size: 13px;
  line-height: 1.6;
  padding: 4px 0;
  color: var(--text);
  border-bottom: 1px dashed var(--border);
}

.mgmt-list li:last-child {
  border-bottom: none;
}

.mgmt-list li.risk-danger {
  color: var(--danger);
  font-weight: 600;
}

.mgmt-list li.risk-danger::before {
  content: '● ';
  font-size: 10px;
}

.mgmt-list li.risk-warning {
  color: #92400e;
}

.mgmt-list li.risk-warning::before {
  content: '● ';
  font-size: 10px;
  color: var(--warning);
}

.mgmt-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 0;
}

/* 趋势指标 */
.stat-trend {
  font-size: 12px;
  margin-top: 4px;
  font-weight: 600;
}

.trend-up {
  color: var(--success);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.trend-down {
  color: var(--danger);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.trend-flat {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.trend-warning {
  color: #92400e;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

/* 迷你趋势图 */
.mini-chart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 120px;
  padding: 10px 0;
}

.mini-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}

.mini-bar-val {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.mini-bar {
  width: 100%;
  max-width: 60px;
  border-radius: 6px 6px 2px 2px;
  transition: height 0.3s ease;
  min-height: 4px;
}

.mini-bar.current {
  box-shadow: 0 0 0 2px rgba(37,99,235,0.2);
}

.mini-bar-label {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* 管理层摘要响应式 */
@media (max-width: 768px) {
  .mgmt-summary {
    grid-template-columns: 1fr;
  }
  .mgmt-section {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .mgmt-section:last-child {
    border-bottom: none;
  }
}

/* ================= 管理层表达压缩 ================= */
.cmp-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.cmp-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.cmp-input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  gap: 12px;
}
.cmp-count {
  font-size: 12px;
  color: var(--text-muted);
}
.cmp-sections {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
  border-radius: 10px;
  padding: 14px;
  border: 1px solid var(--border);
}
.cmp-sec {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.6;
}
.cmp-sec-label {
  flex-shrink: 0;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  margin-top: 2px;
  white-space: nowrap;
}
.cmp-sec-text {
  font-size: 14px;
  color: var(--text);
}
.cmp-sep {
  color: var(--border);
  margin: 0 6px;
}
.cmp-output-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.cmp-compare {
  overflow-x: auto;
}
.cmp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cmp-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  background: var(--bg);
  white-space: nowrap;
}
.cmp-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.6;
}
.cmp-from {
  color: var(--text-secondary);
}
.cmp-to {
  color: var(--text);
  font-weight: 500;
}
.cmp-why {
  font-size: 12px;
  color: var(--text-muted);
}
.cmp-row-del td {
  background: var(--danger-light);
}
.cmp-row-del .cmp-from s {
  color: var(--danger);
  opacity: 0.75;
}
.cmp-row-keep td {
  background: var(--success-light);
}
.cmp-del-type {
  font-size: 11px;
  color: var(--danger);
  font-weight: 600;
}
.cmp-tips {
  margin-top: 16px;
  background: var(--info-light);
  border: 1px dashed var(--info);
  border-radius: 10px;
  padding: 12px 16px;
}
.cmp-tips-title {
  font-weight: 700;
  color: var(--info);
  margin-bottom: 6px;
}
.cmp-tips ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
}
.cmp-tips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.cmp-tip-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.cmp-tip-item b {
  color: var(--text);
}
.cmp-tip-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.cmp-history-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--bg);
}
.cmp-history-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.cmp-history-note {
  flex: 1;
  min-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 压缩模块响应式 */
@media (max-width: 900px) {
  .cmp-layout {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   经营分析驾驶舱 (Analytics Cockpit)
   ============================================================ */
.dim-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.dim-tab {
  padding: 8px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all .15s;
}
.dim-tab:hover { border-color: var(--primary); color: var(--primary); }
.dim-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.dim-hint { font-size: 12px; color: var(--text-muted); margin-left: 6px; }

.section-block { margin-bottom: 30px; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.section-title { font-size: 16px; font-weight: 700; }
.section-sub { font-size: 12px; color: var(--text-muted); }

/* 紧凑指标网格 */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.metric-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
}
.metric-card.c-blue::before { background: var(--primary); }
.metric-card.c-green::before { background: var(--success); }
.metric-card.c-orange::before { background: var(--warning); }
.metric-card.c-red::before { background: var(--danger); }
.metric-card.c-purple::before { background: var(--purple); }
.metric-card.c-cyan::before { background: var(--info); }
.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}
.metric-value {
  font-size: 22px;
  font-weight: 700;
  margin-top: 2px;
  color: var(--text);
}
.metric-value.sm { font-size: 16px; line-height: 1.4; }
.metric-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.metric-card.insufficient { background: var(--bg); }
.metric-card.insufficient::before { background: var(--text-muted); }
.metric-card.insufficient .metric-value {
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 600;
}

/* 工作 vs 结果 摘要卡 */
.work-result {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 26px;
}
.wr-card { border-radius: 12px; padding: 18px 22px; }
.wr-work { background: linear-gradient(135deg, #eff6ff, #dbeafe); border: 1px solid #bfdbfe; }
.wr-result { background: linear-gradient(135deg, #f0fdf4, #dcfce7); border: 1px solid #bbf7d0; }
.wr-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.wr-period { font-size: 11px; font-weight: 400; color: var(--text-secondary); }
.wr-items { display: flex; gap: 24px; flex-wrap: wrap; }
.wr-item .n { font-size: 21px; font-weight: 800; line-height: 1.2; }
.wr-item .t { font-size: 11px; color: var(--text-secondary); }

/* 转化漏斗 */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: flex; align-items: center; gap: 12px; }
.funnel-label {
  width: 130px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: right;
  flex: 0 0 auto;
}
.funnel-bar-wrap {
  flex: 1;
  background: var(--bg);
  border-radius: 8px;
  overflow: hidden;
  height: 42px;
  position: relative;
}
.funnel-bar {
  height: 100%;
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  min-width: 44px;
  transition: width .4s;
  white-space: nowrap;
}
.funnel-ratio {
  font-size: 11px;
  color: var(--text-muted);
  width: 42px;
  flex: 0 0 auto;
}

/* 转化率卡 */
.conv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.conv-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.conv-rate { font-size: 21px; font-weight: 800; }
.conv-label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; font-weight: 600; }

/* 高风险客户列表 */
.risk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
  flex-wrap: wrap;
}
.risk-item:last-child { border-bottom: none; }
.risk-score {
  background: var(--danger-light);
  color: var(--danger);
  font-weight: 700;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}

/* 趋势 */
.trend-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.trend-tab {
  padding: 5px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all .15s;
}
.trend-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.trend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 16px;
}
.trend-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.trend-card-title { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 130px;
  padding-top: 8px;
}
.t-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
  min-width: 0;
}
.t-bar {
  width: 100%;
  max-width: 28px;
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height .3s;
}
.t-val { font-size: 10px; color: var(--text-secondary); white-space: nowrap; }
.t-label { font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.t-col.current .t-val { color: var(--primary); font-weight: 700; }

/* 口径说明 */
.note-block {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 12px;
  color: var(--text-secondary);
}
.note-block summary { color: var(--text); }

@media (max-width: 900px) {
  .work-result { grid-template-columns: 1fr; }
  .funnel-label { width: 96px; }
}

/* ============================================================
   趋势对比分析 (Compare)
   ============================================================ */
.compare-intro {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.compare-table {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.compare-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.2fr 1fr;
  align-items: center;
  gap: 0;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.compare-row:last-child { border-bottom: none; }
.compare-row:nth-child(even) { background: var(--bg); }
.compare-header {
  background: var(--surface);
  font-weight: 700;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cth-label, .ctd-label { text-align: left; }
.cth-val, .ctd-val { text-align: center; }
.ctd-label { font-weight: 600; }
.compare-delta {
  font-size: 12px;
  font-weight: 600;
}
.compare-rate {
  font-size: 13px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}
.delta-up { color: var(--success); }
.delta-up .compare-rate { background: var(--success-bg, rgba(22,163,74,.1)); }
.delta-down { color: var(--danger); }
.delta-down .compare-rate { background: var(--danger-bg, rgba(220,38,38,.1)); }
.delta-flat { color: var(--text-muted); }
.delta-flat .compare-rate { background: var(--bg); }

/* ============================================================
   年度目标完成率 (YTD)
   ============================================================ */
.ytd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}
.ytd-intro {
  font-size: 13px;
  color: var(--text-secondary);
}
.ytd-no-target {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.ytd-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ytd-item {
  display: grid;
  grid-template-columns: 1.5fr 2fr 2fr 2fr;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.ytd-item:last-child { border-bottom: none; }
.ytd-label { font-size: 13px; font-weight: 600; }
.ytd-value { font-size: 14px; font-weight: 700; }
.ytd-unit { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.ytd-target { font-size: 12px; color: var(--text-muted); }
.ytd-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ytd-bar {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}
.ytd-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .3s;
}
.ytd-rate {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.ytd-gap {
  font-size: 11px;
  color: var(--text-muted);
}

/* ============================================================
   趋势预测 (Forecast)
   ============================================================ */
.forecast-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.forecast-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.forecast-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
  background: var(--primary);
}
.forecast-card.low-confidence::before { background: var(--warning); }
.forecast-card.insufficient::before { background: var(--text-muted); }
.fc-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}
.fc-actual, .fc-predicted {
  font-size: 13px;
  margin-bottom: 8px;
  line-height: 1.6;
}
.fc-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 4px;
  margin-right: 6px;
}
.fc-tag.actual {
  background: rgba(37,99,235,.12);
  color: var(--primary);
}
.fc-tag.predicted {
  background: rgba(217,119,6,.12);
  color: var(--warning);
}
.fc-tag.insufficient-tag {
  background: var(--bg);
  color: var(--text-muted);
}
.fc-basis {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 6px;
  padding: 8px 10px;
  margin-top: 8px;
  line-height: 1.5;
}
.fc-warn {
  font-size: 11px;
  color: var(--warning);
  margin-top: 6px;
  font-weight: 600;
}
.fc-reason {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}
.forecast-disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 6px;
  line-height: 1.6;
}

/* =========================================================
   管理层首页看板（经营总览）
   设计：少文字 · 强数据 · 强结果 · 强趋势
   ========================================================= */

/* 1. 核心数据 hero 瓦片 */
.mgmt-hero {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.hero-tile {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px 12px;
  overflow: hidden;
  min-height: 104px;
  display: flex;
  flex-direction: column;
}
.hero-tile::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--primary);
}
.hero-tile.accent-blue::before { background: var(--primary); }
.hero-tile.accent-cyan::before { background: var(--info); }
.hero-tile.accent-green::before { background: var(--success); }
.hero-tile.accent-orange::before { background: var(--warning); }
.hero-tile.accent-purple::before { background: var(--purple); }
.hero-tile.accent-red::before { background: var(--danger); }
.hero-tile.is-alert { background: var(--danger-light); border-color: #fecaca; }
.hero-tile.is-alert::before { background: var(--danger); }
.h-label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.h-value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1.1; margin-top: 6px; letter-spacing: -0.5px; }
.h-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.h-delta { position: absolute; right: 12px; top: 12px; font-size: 12px; font-weight: 700; }
.h-delta.up { color: var(--success); }
.h-delta.down { color: var(--danger); }
.h-delta.flat { color: var(--text-muted); }
.h-pill { position: absolute; right: 12px; top: 12px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.pill-alert { background: var(--danger); color: #fff; }
.pill-ok { background: var(--success-light); color: var(--success); }

/* 2. 与上周相比条 */
.vs-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.vs-strip-label { font-weight: 700; font-size: 13px; color: var(--text); margin-right: 4px; }
.vs-chip { font-size: 12px; color: var(--text-secondary); padding: 3px 10px; border-radius: 14px; background: var(--bg); }
.vs-chip b { font-weight: 700; }
.vs-chip.up b { color: var(--success); }
.vs-chip.down b { color: var(--danger); }
.vs-chip.flat b { color: var(--text-muted); }
.vs-strip-note { font-size: 11px; color: var(--text-muted); margin-left: auto; }

/* 通用 section 卡片 */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}
.section-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.section-card-title { font-size: 15px; font-weight: 700; color: var(--text); }
.sc-sub { font-size: 12px; font-weight: 400; color: var(--text-muted); margin-left: 8px; }
.section-card-body { padding: 14px 18px; }
.empty-hint { font-size: 13px; color: var(--text-muted); padding: 8px 0; }

.btn-primary-soft {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid var(--primary-light);
}
.btn-primary-soft:hover { background: #c7dbfd; }

/* 3. 本月完成情况 */
.month-row {
  display: grid;
  grid-template-columns: 110px 1fr 220px;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.month-row:last-child { border-bottom: none; }
.mr-label { font-size: 13px; font-weight: 600; color: var(--text); }
.mr-bar-wrap { display: flex; align-items: center; }
.mr-bar { flex: 1; height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.mr-fill { height: 100%; border-radius: 6px; }
.mr-nums { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.mr-actual { font-size: 14px; font-weight: 700; color: var(--text); }
.mr-unit { font-size: 11px; color: var(--text-muted); font-weight: 400; margin-left: 2px; }
.mr-sep { color: var(--text-muted); }
.mr-target { font-size: 13px; color: var(--text-secondary); }
.mr-rate { font-size: 14px; font-weight: 700; margin-left: 4px; }
.mr-gap { grid-column: 2 / 4; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.month-row.no-target .mr-target { color: var(--text-muted); }

/* 4 & 5. 风险 / 机会 */
.mgmt-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.risk-row, .opp-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.risk-row:last-child, .opp-row:last-child { border-bottom: none; }
.risk-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.sev-high { background: var(--danger); }
.sev-mid { background: var(--warning); }
.risk-row.sev-high { background: linear-gradient(90deg, var(--danger-light), transparent 60%); }
.risk-row.sev-mid { background: linear-gradient(90deg, var(--warning-light), transparent 60%); }
.opp-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.risk-main, .opp-main { flex: 1; min-width: 0; }
.risk-title, .opp-title { font-size: 14px; font-weight: 700; color: var(--text); }
.risk-detail, .opp-detail { font-size: 12px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 6. 本周结果横幅 */
.result-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.rb-label { font-size: 13px; font-weight: 700; background: rgba(255,255,255,0.2); padding: 4px 12px; border-radius: 8px; flex-shrink: 0; }
.rb-text { font-size: 15px; font-weight: 600; line-height: 1.5; }

/* 7. 下周重点 */
.actions-list { display: flex; flex-direction: column; gap: 10px; }
.action-item { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--text); }
.action-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex-shrink: 0; }

/* 8. 趋势迷你图 */
.trend-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.trend-mini { background: var(--bg); border-radius: 10px; padding: 12px 14px; }
.tm-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.tm-chart { display: flex; align-items: flex-end; gap: 4px; height: 90px; }
.tm-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.tm-val { font-size: 9px; color: var(--text-muted); margin-bottom: 3px; white-space: nowrap; }
.tm-bar { width: 100%; max-width: 22px; border-radius: 3px 3px 0 0; min-height: 3px; transition: height 0.3s; }
.tm-col.current .tm-bar { box-shadow: 0 0 0 2px rgba(37,99,235,0.2); }
.tm-label { font-size: 9px; color: var(--text-muted); margin-top: 4px; transform: rotate(-35deg); transform-origin: top center; white-space: nowrap; }
.tm-foot { font-size: 11px; color: var(--text-muted); margin-top: 8px; }

@media (max-width: 1100px) {
  .mgmt-hero { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 820px) {
  .mgmt-hero { grid-template-columns: repeat(2, 1fr); }
  .mgmt-two-col { grid-template-columns: 1fr; }
  .trend-strip { grid-template-columns: 1fr; }
  .month-row { grid-template-columns: 90px 1fr; }
  .month-row .mr-gap { grid-column: 1 / 3; }
  .month-row .mr-nums { grid-column: 1 / 3; }
}

/* ============ AI 工作分析助手 ============ */
.ai-note {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  line-height: 1.6;
}
.prio-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.prio-high { background: #fee2e2; color: #b91c1c; }
.prio-medium { background: #fef3c7; color: #b45309; }
.prio-low { background: #e0f2fe; color: #0369a1; }
.insight-link {
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  margin-left: 8px;
  white-space: nowrap;
}
.insight-link:hover { text-decoration: underline; }
.ai-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 10px 4px;
  font-style: italic;
}

/* 今日最值得关注 */
.focus-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.focus-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 10px;
  padding: 14px 16px;
}
.prio-border-high { border-left-color: var(--danger); }
.prio-border-medium { border-left-color: var(--warning); }
.prio-border-low { border-left-color: var(--primary); }
.focus-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.focus-name { font-weight: 700; font-size: 15px; }
.focus-analysis {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 8px;
}
.focus-rec {
  font-size: 13px;
  font-weight: 600;
  color: var(--success);
  margin-top: 8px;
  line-height: 1.6;
}

/* 深度洞察网格 */
.ai-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}
.ai-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.ai-panel-head {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.ai-panel-sub { font-weight: 400; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ai-panel-body { padding: 12px 16px; }

/* 单条洞察 */
.insight { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.insight:last-child { border-bottom: none; }
.insight-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.insight-title { font-weight: 600; font-size: 14px; }
.insight-label { font-size: 12px; font-weight: 700; color: var(--primary); margin-top: 6px; }
.insight-evidence { margin: 4px 0 0 2px; padding-left: 16px; }
.insight-evidence li { font-size: 13px; color: var(--text-muted); line-height: 1.7; }
.insight-evidence.sm li { font-size: 12px; line-height: 1.6; }
.insight-analysis { font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.insight-rec { font-size: 13px; font-weight: 600; color: var(--success); line-height: 1.6; }

/* 本周工作重点列表 */
.focus-list { display: flex; flex-direction: column; gap: 10px; }
.focus-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 10px;
  padding: 12px 14px;
}
.focus-num {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.focus-row-body { flex: 1; }
.focus-row-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.focus-row-rec { font-size: 13px; color: var(--success); font-weight: 600; margin-top: 4px; line-height: 1.6; }

/* 每周报告 */
.weekly-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.weekly-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.weekly-h {
  padding: 10px 14px;
  font-weight: 700;
  font-size: 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.weekly-body { padding: 12px 14px; }
.wr-line { font-size: 13px; line-height: 1.8; color: var(--text-muted); }
.wr-line strong { color: var(--text); }
.wr-line.up { color: var(--success); }
.wr-line.down { color: var(--danger); }
.wr-line.flat { color: var(--text-muted); }

@media (max-width: 900px) {
  .focus-grid { grid-template-columns: 1fr; }
  .ai-grid { grid-template-columns: 1fr; }
  .weekly-grid { grid-template-columns: 1fr; }
}

/* ============ Boss Follow-up 老板任务跟进 ============ */
.bf-summary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.bf-pill { display: flex; flex-direction: column; align-items: center; min-width: 78px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.bf-pill-n { font-size: 22px; font-weight: 700; line-height: 1.1; }
.bf-pill-l { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.bf-pill.p-today .bf-pill-n { color: var(--primary); }
.bf-pill.p-overdue .bf-pill-n { color: var(--danger); }
.bf-pill.p-upcoming .bf-pill-n { color: var(--warning); }
.bf-pill.p-ongoing .bf-pill-n { color: var(--info); }
.bf-pill.p-done .bf-pill-n { color: var(--success); }

.bf-alert { display: flex; align-items: center; gap: 10px; padding: 12px 16px; margin-bottom: 16px; background: var(--danger-light); border: 1px solid var(--danger); border-radius: var(--radius); color: var(--danger); font-size: 13px; }

.bf-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.bf-section-overdue { border-color: var(--danger); }
.bf-section-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--bg); }
.bf-section-icon { font-size: 16px; }
.bf-section-title { font-weight: 700; font-size: 14px; }
.bf-count { margin-left: auto; min-width: 24px; height: 24px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-light); color: var(--primary); border-radius: 12px; font-size: 12px; font-weight: 700; }
.bf-count.danger { background: var(--danger-light); color: var(--danger); }
.bf-section-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.bf-empty { color: var(--text-muted); font-size: 13px; padding: 6px 0; }

.bf-dept { display: inline-block; padding: 1px 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; font-size: 11px; color: var(--text-secondary); }
.bf-person { font-size: 14px; }
.bf-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.bf-dot.red { background: var(--danger); }
.bf-task { font-size: 14px; color: var(--text); }
.bf-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-secondary); }
.bf-action-tag { color: var(--primary); font-weight: 600; }
.bf-actions { display: flex; gap: 8px; margin-top: 4px; }
.bf-actions-sm { margin-left: auto; display: flex; gap: 6px; }

.bf-today-card { border: 1px solid var(--danger); background: var(--danger-light); border-radius: var(--radius-sm); padding: 12px 14px; }
.bf-row-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }

.bf-up-item, .bf-cp-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }
.bf-date { font-weight: 700; color: var(--warning); min-width: 56px; }
.bf-sep { color: var(--text-muted); }
.bf-task-sm { color: var(--text-secondary); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bf-ongoing-card { border: 1px solid var(--info); background: var(--info-light); border-radius: var(--radius-sm); padding: 12px 14px; }
.bf-follow-status { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.bf-follow-status.due { color: var(--warning); font-weight: 600; }

.bf-ov-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--danger); background: var(--danger-light); border-radius: var(--radius-sm); }
.bf-ov-badge { background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 10px; white-space: nowrap; }
.bf-ov-main { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; font-size: 13px; }
.bf-ov-deadline { color: var(--danger); font-size: 12px; font-weight: 600; }

.bf-cp-item { background: var(--success-light); border-color: var(--success); }
.bf-check { color: var(--success); font-weight: 700; }
.bf-result { font-size: 12px; color: var(--text-secondary); background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 1px 8px; }

.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

@media (max-width: 700px) {
  .bf-up-item, .bf-ov-item, .bf-cp-item { flex-wrap: wrap; }
  .bf-task-sm { flex-basis: 100%; }
}

/* === 停止服务分析：客户主数据联动 === */
.ss-lookup { position: relative; }
.ss-suggest {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 60;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px); box-shadow: 0 8px 24px rgba(15,23,42,.16);
  max-height: 260px; overflow-y: auto; margin-top: 4px;
}
.ss-suggest-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border);
}
.ss-suggest-item:last-child { border-bottom: none; }
.ss-suggest-item:hover { background: var(--bg); }
.ss-suggest-name { font-weight: 600; font-size: 14px; color: var(--text); }
.ss-suggest-meta { font-size: 12px; color: var(--text-muted); }
.ss-cust-link { color: var(--primary); text-decoration: none; cursor: pointer; }
.ss-cust-link:hover { text-decoration: underline; }
