/* ============================================================
   AI Analysis Unified Framework — CSS v1.0
   Phase 1: 六段式卡片 + Shell + Sections + 状态覆盖层
   ============================================================ */

/* ── Shell ── */
.ai-af-shell {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 14px;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.ai-af-shell.dark {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

/* ── Header Bar ── */
.ai-af-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: linear-gradient(135deg, rgba(99,102,241,.08), rgba(0,212,170,.06));
}
.ai-af-shell.dark .ai-af-header {
  background: linear-gradient(135deg, rgba(99,102,241,.1), rgba(0,212,170,.06));
  border-bottom-color: #334155;
}
.ai-af-header-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.ai-af-header-text { flex: 1; min-width: 0; }
.ai-af-header-title {
  font-size: 15px; font-weight: 700;
  color: var(--text, #0f172a);
  line-height: 1.3;
}
.ai-af-shell.dark .ai-af-header-title { color: #e2e8f0; }
.ai-af-header-subtitle {
  font-size: 12px; color: var(--text-muted, #64748b);
  margin-top: 2px;
}
.ai-af-header-actions { display: flex; align-items: center; gap: 6px; }
.ai-af-header-badge {
  font-size: 10px; padding: 2px 8px;
  border-radius: 10px; font-weight: 600;
  white-space: nowrap;
}
.ai-af-header-badge.llm { background: rgba(99,102,241,.18); color: #4338ca; border: 1px solid rgba(99,102,241,.25); }
.ai-af-header-badge.rule { background: rgba(245,158,11,.18); color: #b45309; border: 1px solid rgba(245,158,11,.25); }
.ai-af-header-badge.cached { background: rgba(34,197,94,.18); color: #15803d; border: 1px solid rgba(34,197,94,.25); }
.ai-af-header-badge.error { background: rgba(239,68,68,.18); color: #b91c1c; border: 1px solid rgba(239,68,68,.25); }

.ai-af-shell.dark .ai-af-header-badge.llm { background: rgba(99,102,241,.22); color: #a5b4fc; border-color: rgba(99,102,241,.4); }
.ai-af-shell.dark .ai-af-header-badge.rule { background: rgba(245,158,11,.22); color: #fcd34d; border-color: rgba(245,158,11,.4); }
.ai-af-shell.dark .ai-af-header-badge.cached { background: rgba(34,197,94,.22); color: #86efac; border-color: rgba(34,197,94,.4); }
.ai-af-shell.dark .ai-af-header-badge.error { background: rgba(239,68,68,.22); color: #fca5a5; border-color: rgba(239,68,68,.4); }
.ai-af-btn-icon {
  width: 30px; height: 30px; border: none; border-radius: 8px;
  cursor: pointer; font-size: 14px; color: var(--text-muted, #64748b);
  background: var(--bg, #f1f5f9);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.ai-af-btn-icon:hover {
  background: var(--primary, #6366f1);
  color: #fff;
}

/* ── Content Body ── */
.ai-af-body {
  padding: 22px 24px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.ai-af-body::-webkit-scrollbar { width: 4px; }
.ai-af-body::-webkit-scrollbar-track { background: transparent; }
.ai-af-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius: 4px; }
.ai-af-shell.dark .ai-af-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); }

/* ── State Overlays ── */
.ai-af-state {
  text-align: center; padding: 48px 20px;
  color: var(--text-muted, #64748b);
}
.ai-af-state-icon { font-size: 40px; margin-bottom: 12px; opacity: .5; }
.ai-af-state-text { font-size: 14px; line-height: 1.6; }
.ai-af-state .spinner {
  display: inline-block; width: 32px; height: 32px;
  border: 3px solid rgba(99,102,241,.15);
  border-top-color: #6366f1;
  border-radius: 50%; animation: ai-af-spin .7s linear infinite;
  margin-bottom: 12px;
}
@keyframes ai-af-spin { to { transform: rotate(360deg); } }

/* ── Section: Hero (Score Gauge) ── */
.ai-af-hero {
  text-align: center; padding: 18px 0;
  margin-bottom: 12px;
}
.ai-af-hero-score {
  font-size: 48px; font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, #6366f1, #00d4aa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.ai-af-hero-level {
  font-size: 14px; font-weight: 700;
  margin-top: 6px;
}
.ai-af-hero-level.healthy { color: #22c55e; }
.ai-af-hero-level.warning { color: #f59e0b; }
.ai-af-hero-level.critical { color: #ef4444; }
.ai-af-hero-level.neutral { color: #6366f1; }
.ai-af-hero-summary {
  font-size: 14px; color: var(--text-muted, #64748b);
  margin-top: 6px; max-width: 440px; margin-left: auto; margin-right: auto;
  line-height: 1.7;
}

/* ── Section: Six-Segment Cards ── */
.ai-af-cards { display: flex; flex-direction: column; gap: 28px; }
.ai-af-card {
  border-radius: 14px; overflow: hidden;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--card-bg, #fff);
  transition: box-shadow .2s, transform .15s;
}
.ai-af-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.08); transform: translateY(-1px); }
.ai-af-card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 22px; font-weight: 700; font-size: 15px;
}
.ai-af-card-header .ai-af-card-icon { font-size: 18px; flex-shrink: 0; }
.ai-af-card-header .ai-af-card-title { flex: 1; word-break: break-word; white-space: normal; }
.ai-af-card-priority {
  font-size: 12px; padding: 3px 10px; border-radius: 5px;
  font-weight: 700; color: #fff;
}
.ai-af-card-priority.high { background: #ef4444; }
.ai-af-card-priority.mid  { background: #f59e0b; }
.ai-af-card-priority.low  { background: #94a3b8; }

.ai-af-card-body {
  padding: 0 24px 20px; }
.ai-af-card-segment {
  font-size: 14px; line-height: 1.9;
  padding: 18px 0;
  border-bottom: 1px solid rgba(0,0,0,.05);
  position: relative;
}
.ai-af-shell.dark .ai-af-card-segment { border-bottom-color: rgba(255,255,255,.05); }
.ai-af-card-segment:last-child { border-bottom: none; }
.ai-af-card-segment .ai-af-label {
  display: inline-block; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  margin-right: 8px; padding: 2px 7px;
  border-radius: 4px;
}
.ai-af-label-fact   { background: rgba(14,165,233,.18); color: #0369a1; }
.ai-af-label-cause  { background: rgba(249,115,22,.18); color: #c2410c; }
.ai-af-label-action { background: rgba(99,102,241,.18);  color: #4338ca; }
.ai-af-label-budget { background: rgba(34,197,94,.18);  color: #15803d; }
.ai-af-label-effect { background: rgba(139,92,246,.18); color: #6b21a8; }
.ai-af-label-risk   { background: rgba(239,68,68,.18);  color: #b91c1c; }

/* ── Dark Mode 标签覆盖 ── */
.ai-af-shell.dark .ai-af-label-fact   { background: rgba(14,165,233,.22); color: #38bdf8; }
.ai-af-shell.dark .ai-af-label-cause  { background: rgba(249,115,22,.22); color: #fb923c; }
.ai-af-shell.dark .ai-af-label-action { background: rgba(99,102,241,.22);  color: #818cf8; }
.ai-af-shell.dark .ai-af-label-budget { background: rgba(34,197,94,.22);  color: #4ade80; }
.ai-af-shell.dark .ai-af-label-effect { background: rgba(139,92,246,.22); color: #c084fc; }
.ai-af-shell.dark .ai-af-label-risk   { background: rgba(239,68,68,.22);  color: #f87171; }

/* ── KPI 高亮徽章 ── */
.ai-af-kpi-badge {
  display: inline-block;
  background: linear-gradient(135deg, rgba(99,102,241,.08), rgba(99,102,241,.03));
  border: 1px solid rgba(99,102,241,.15);
  border-radius: 6px;
  padding: 2px 8px;
  margin: 0 2px;
  font-weight: 700;
  font-size: 12px;
  color: #4f46e5;
}

/* ── 展开/收起 ── */
.ai-af-segment-collapsed {
  max-height: 2.6em;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
  cursor: pointer;
}
.ai-af-segment-collapsed.expanded {
  max-height: none;
  mask-image: none;
  -webkit-mask-image: none;
}
.ai-af-expand-btn {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: #6366f1;
  cursor: pointer;
  user-select: none;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(99,102,241,.15);
  background: rgba(99,102,241,.04);
  transition: all .15s;
}
.ai-af-expand-btn:hover {
  background: rgba(99,102,241,.1);
  border-color: #6366f1;
}

.ai-af-card-feedback {
  display: flex; gap: 6px; padding: 8px 16px;
  border-top: 1px solid rgba(0,0,0,.05);
  font-size: 12px; color: var(--text-muted, #94a3b8);
}
.ai-af-shell.dark .ai-af-card-feedback { border-top-color: rgba(255,255,255,.05); }
.ai-af-fb-btn {
  border: none; background: transparent; cursor: pointer;
  font-size: 14px; padding: 3px 8px; border-radius: 6px;
  transition: all .15s; color: var(--text-muted, #94a3b8);
}
.ai-af-fb-btn:hover { background: rgba(99,102,241,.1); color: #6366f1; }
.ai-af-fb-btn.active[data-rating="up"]   { color: #22c55e; background: rgba(34,197,94,.1); }
.ai-af-fb-btn.active[data-rating="down"] { color: #ef4444; background: rgba(239,68,68,.1); }

/* ── Phase 3: 点踩原因弹窗 ── */
.ai-af-dislike-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  animation: ai-af-fadeIn .15s ease;
}
@keyframes ai-af-fadeIn { from{opacity:0} to{opacity:1} }
.ai-af-dislike-dialog {
  background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.15);
  max-width: 360px; width: 90%; overflow: hidden;
}
.ai-af-shell.dark .ai-af-dislike-dialog { background: #1e293b; }
.ai-af-dislike-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; font-size: 13px; font-weight: 600;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.ai-af-shell.dark .ai-af-dislike-header { border-bottom-color: rgba(255,255,255,.06); }
.ai-af-dislike-body { padding: 12px 16px; }
.ai-af-dislike-reasons {
  display: flex; flex-direction: column; gap: 6px;
}
.ai-af-dislike-reason {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; font-size: 13px;
  border: 1px solid rgba(0,0,0,.08); transition: all .15s;
}
.ai-af-dislike-reason:hover { background: rgba(99,102,241,.04); border-color: rgba(99,102,241,.2); }
.ai-af-dislike-reason:has(input:checked) {
  background: rgba(99,102,241,.08); border-color: #6366f1;
}
.ai-af-dislike-reason input[type="radio"] { accent-color: #6366f1; }
.ai-af-dislike-reason-label { flex: 1; }
.ai-af-dislike-detail {
  width: 100%; margin-top: 10px; padding: 8px 10px;
  border: 1px solid rgba(0,0,0,.1); border-radius: 8px;
  font-size: 13px; resize: vertical; outline: none;
  box-sizing: border-box;
}
.ai-af-dislike-detail:focus { border-color: #6366f1; }
.ai-af-dislike-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 10px 16px; border-top: 1px solid rgba(0,0,0,.06);
}
.ai-af-shell.dark .ai-af-dislike-footer { border-top-color: rgba(255,255,255,.06); }
.ai-af-dislike-footer .ai-af-btn {
  padding: 7px 16px; border-radius: 8px; font-size: 13px; font-weight: 500;
  border: none; cursor: pointer; transition: all .15s;
}
.ai-af-dislike-footer .ai-af-btn:hover { opacity: .85; }

/* ── Section: Summary ── */
.ai-af-summary {
  background: linear-gradient(90deg, rgba(99,102,241,.08), rgba(99,102,241,.02));
  border-left: 3px solid #6366f1;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px; line-height: 1.9;
  color: var(--text, #1e293b);
}
.ai-af-shell.dark .ai-af-summary {
  background: linear-gradient(90deg, rgba(99,102,241,.15), rgba(99,102,241,.04));
  color: #e2e8f0;
}
.ai-af-summary-icon { margin-right: 6px; }

/* ── Section: Good/Bad ── */
.ai-af-goodbad {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 16px;
}
.ai-af-goodbad-col {
  border-radius: 12px; padding: 14px;
  border: 1px solid var(--border, #e2e8f0);
}
.ai-af-goodbad-col.good { background: rgba(34,197,94,.04); border-color: rgba(34,197,94,.2); }
.ai-af-goodbad-col.bad  { background: rgba(239,68,68,.04);  border-color: rgba(239,68,68,.2); }
.ai-af-goodbad-title {
  font-size: 13px; font-weight: 700; margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.ai-af-goodbad-item {
  font-size: 13px; padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,.04);
  display: flex; align-items: center; gap: 6px;
}
.ai-af-goodbad-item:last-child { border-bottom: none; }

/* ── Section: Alerts ── */
.ai-af-alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.9; }

/* ── Section: Benchmark ── */
.ai-af-benchmark { margin-bottom: 12px; }
.ai-af-benchmark-title {
  font-size: 13px; font-weight: 700;
  margin-bottom: 8px; color: var(--text, #1e293b);
}
.ai-af-benchmark-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px; font-size: 12px;
}
.ai-af-benchmark-label { width: 70px; flex-shrink: 0; color: var(--text-muted, #64748b); }
.ai-af-benchmark-bar-wrap {
  flex: 1; height: 8px; background: rgba(0,0,0,.06);
  border-radius: 4px; overflow: hidden; position: relative;
}
.ai-af-shell.dark .ai-af-benchmark-bar-wrap { background: rgba(255,255,255,.06); }
.ai-af-benchmark-bar {
  height: 100%; border-radius: 4px; transition: width .6s ease;
}
.ai-af-benchmark-bar.above { background: linear-gradient(90deg, #22c55e, #10b981); }
.ai-af-benchmark-bar.average { background: linear-gradient(90deg, #f59e0b, #f97316); }
.ai-af-benchmark-bar.below { background: linear-gradient(90deg, #ef4444, #dc2626); }
.ai-af-benchmark-value { width: 60px; text-align: right; font-weight: 600; flex-shrink: 0; }
.ai-af-benchmark-rank {
  text-align: center; padding: 8px;
  background: rgba(99,102,241,.06);
  border-radius: 8px; margin-top: 8px;
  font-size: 12px; color: #6366f1; font-weight: 600;
}

/* ── Follow-up Chat Area (可折叠) ── */
.ai-af-followup {
  padding: 0;
  border-top: 2px solid rgba(99,102,241,.15);
  background: linear-gradient(180deg, rgba(99,102,241,.03), rgba(99,102,241,.06));
  flex-shrink: 0;
  overflow: hidden;
}
.ai-af-shell.dark .ai-af-followup {
  background: linear-gradient(180deg, rgba(99,102,241,.06), rgba(99,102,241,.1));
  border-top-color: rgba(99,102,241,.25);
}
.ai-af-followup-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.ai-af-followup-header:hover {
  background: rgba(99,102,241,.04);
}
.ai-af-followup-toggle {
  border: none; background: transparent; cursor: pointer;
  font-size: 16px; color: var(--text-muted, #94a3b8);
  width: 28px; height: 28px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.ai-af-followup-toggle:hover {
  background: rgba(99,102,241,.1); color: #6366f1;
}
.ai-af-followup-body {
  padding: 0 18px 18px;
  transition: max-height .3s ease, padding .3s ease, opacity .2s ease;
  max-height: 1200px;
  opacity: 1;
  overflow: hidden;
}
.ai-af-followup-body.collapsed {
  max-height: 0;
  padding: 0 18px 0;
  opacity: 0;
}
.ai-af-followup-label {
  font-size: 13px; font-weight: 700;
  color: var(--text, #1e293b);
  display: flex; align-items: center; gap: 8px;
  margin: 0;
}
.ai-af-followup-label .ai-af-chat-icon {
  width: 24px; height: 24px;
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.ai-af-followup-hint {
  font-size: 12px; color: var(--text-muted, #94a3b8);
  margin-bottom: 12px; line-height: 1.5;
}
.ai-af-quick-asks {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.ai-af-quick-ask {
  font-size: 13px; padding: 7px 14px;
  border-radius: 18px; cursor: pointer;
  background: var(--card-bg, #fff);
  color: #4f46e5; border: 1.5px solid rgba(99,102,241,.25);
  white-space: nowrap; transition: all .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  font-weight: 500;
}
.ai-af-quick-ask:hover {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 3px 12px rgba(99,102,241,.3);
  transform: translateY(-1px);
}
.ai-af-ask-row {
  display: flex; gap: 8px;
}
.ai-af-ask-input {
  flex: 1; padding: 11px 16px;
  border: 2px solid rgba(99,102,241,.2);
  border-radius: 12px;
  background: var(--card-bg, #fff);
  color: var(--text, #1e293b);
  font-size: 13px; outline: none;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: 0 0 0 0 transparent;
}
.ai-af-ask-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 4px rgba(99,102,241,.1);
}
.ai-af-ask-input::placeholder { color: #94a3b8; font-size: 13px; }
.ai-af-ask-btn {
  padding: 11px 22px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: all .2s;
  box-shadow: 0 2px 10px rgba(99,102,241,.3);
  letter-spacing: .02em;
}
.ai-af-ask-btn:hover { opacity: .92; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(99,102,241,.4); }
.ai-af-ask-btn:disabled { opacity: .5; cursor: wait; transform: none; box-shadow: none; }

/* ── 追问区底部升级出口（去经营大脑深度汇报，仅传入 followUpAction 的入口显示） ── */
.ai-af-brain-row {
  display: flex; justify-content: flex-start;
  margin-top: 10px;
}
.ai-af-brain-btn {
  display: inline-flex; align-items: center;
  padding: 5px 12px; border: 1px solid rgba(245,158,11,.55);
  border-radius: 8px; background: transparent;
  color: #f59e0b; font-size: 12px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: all .2s;
}
.ai-af-brain-btn:hover {
  color: #fbbf24; border-color: #f59e0b;
  background: rgba(245,158,11,.12);
}
.ai-af-brain-btn:active { transform: translateY(1px); }
.ai-af-shell.dark .ai-af-brain-btn {
  color: #fbbf24;
  border-color: rgba(245,158,11,.55);
}
.ai-af-shell.dark .ai-af-brain-btn:hover {
  color: #fde047; border-color: #f59e0b;
  background: rgba(245,158,11,.16);
}
.ai-af-shell.dark .ai-af-quick-ask {
  color: #a5b4fc;
  border-color: rgba(129,140,248,.35);
}

/* ── Chat Conversation History (可拖拽调整高度) ── */
.ai-af-chat-history {
  margin-bottom: 0;
  display: flex; flex-direction: column; gap: 14px;
  max-height: 300px; min-height: 40px; height: auto;
  overflow-y: auto;
  padding-right: 6px;
  padding-bottom: 4px;
  transition: none;
}
.ai-af-chat-history::-webkit-scrollbar { width: 6px; }
.ai-af-chat-history::-webkit-scrollbar-track { background: transparent; }
.ai-af-chat-history::-webkit-scrollbar-thumb { background: rgba(99,102,241,.35); border-radius: 3px; }
.ai-af-chat-history::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,.55); }
.ai-af-chat-msg {
  padding: 10px 14px; border-radius: 10px;
  font-size: 12px; line-height: 1.8;
  max-width: 85%; word-break: break-word;
  animation: ai-af-msgIn .2s ease;
}
.ai-af-chat-msg p {
  margin: 0 0 10px 0;
}
.ai-af-chat-msg p:last-child {
  margin-bottom: 0;
}
.ai-af-chat-msg b,
.ai-af-chat-msg strong {
  font-weight: 700;
  color: #0f172a;
}
.ai-af-shell.dark .ai-af-chat-msg b,
.ai-af-shell.dark .ai-af-chat-msg strong {
  color: #e2e8f0;
}
@keyframes ai-af-msgIn { from{opacity:0;transform:translateY(4px)} to{opacity:1;transform:translateY(0)} }
.ai-af-chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.ai-af-chat-msg.ai {
  align-self: flex-start;
  background: var(--bg, #f1f5f9);
  color: var(--text, #334155);
  border-bottom-left-radius: 3px;
}
.ai-af-shell.dark .ai-af-chat-msg.ai {
  background: #1e293b;
  color: #e2e8f0;
}

/* ── Chat History Resize Handle ── */
.ai-af-chat-resize-handle {
  height: 8px; cursor: ns-resize;
  margin: 0 -18px 10px;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
  border-radius: 2px;
}
.ai-af-chat-resize-handle:hover {
  background: rgba(99,102,241,.08);
}
.ai-af-chat-resize-handle span {
  display: block;
  width: 36px; height: 3px;
  background: rgba(99,102,241,.2);
  border-radius: 2px;
  transition: background .15s, width .15s;
}
.ai-af-chat-resize-handle:hover span {
  background: rgba(99,102,241,.5);
  width: 48px;
}

/* ── Dimension Selector (Phase 2 ready) ── */
.ai-af-dims {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--bg, #f8fafc);
}
.ai-af-dim {
  font-size: 11px; padding: 4px 14px;
  border-radius: 14px; cursor: pointer;
  border: 1.5px solid #d4d4d8;
  background: #f4f4f5;
  color: #a1a1aa;
  font-weight: 500;
  transition: all .2s ease; user-select: none;
  opacity: 0.7;
  letter-spacing: 0.01em;
}
.ai-af-dim:hover {
  opacity: 0.9;
  border-color: #a1a1aa;
  color: #71717a;
}
.ai-af-dim.checked {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  border-color: #6366f1;
  color: #fff;
  font-weight: 700;
  opacity: 1;
  box-shadow: 0 2px 8px rgba(99,102,241,.35);
  letter-spacing: 0.02em;
}
.ai-af-dim.checked:hover {
  background: linear-gradient(135deg, #4f46e5, #6d28d9);
  box-shadow: 0 3px 12px rgba(99,102,241,.5);
  transform: translateY(-1px);
}

/* ── 维度图标（内联选择器中的图标） ── */
.ai-af-dim-icon {
  margin-right: 3px;
  font-size: 12px;
}
/* ── "选择维度" 操作按钮高亮 ── */
.ai-af-dim-action {
  background: rgba(99,102,241,.08);
  border-color: #6366f1;
  color: #6366f1;
  font-weight: 700 !important;
  opacity: 1 !important;
}
.ai-af-dim-action:hover {
  background: rgba(99,102,241,.15) !important;
  border-color: #4f46e5 !important;
  color: #4f46e5 !important;
}

/* ── Phase 2: 维度自选弹窗 ── */
.ai-af-dim-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10000;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: aiAfFadeIn .2s ease;
}
@keyframes aiAfFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.ai-af-dim-modal {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2), 0 0 0 1px rgba(0,0,0,.06);
  width: 560px; max-width: 92vw; max-height: 85vh;
  display: flex; flex-direction: column;
  animation: aiAfSlideUp .25s ease;
}
@keyframes aiAfSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.ai-af-dim-modal-header {
  padding: 20px 24px 12px;
  border-bottom: 1px solid #f1f5f9;
}
.ai-af-dim-modal-header h3 {
  margin: 0 0 4px;
  font-size: 17px; font-weight: 700;
  color: #0f172a;
}
.ai-af-dim-modal-body {
  padding: 16px 24px;
  overflow-y: auto;
  flex: 1;
}

/* 维度分组 */
.ai-af-dim-group {
  margin-bottom: 18px;
}
.ai-af-dim-group:last-child { margin-bottom: 0; }
.ai-af-dim-group-title {
  font-size: 12px; font-weight: 700;
  color: #64748b; text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 10px;
  padding-left: 2px;
}
.ai-af-dim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

/* 维度卡片 */
.ai-af-dim-card {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  background: #fafbfc;
  cursor: pointer;
  transition: all .18s ease;
  user-select: none;
  position: relative;
}
.ai-af-dim-card:hover {
  border-color: #c7d2fe;
  background: #f5f7ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(99,102,241,.08);
}
.ai-af-dim-card.checked {
  border-color: #6366f1;
  background: linear-gradient(135deg, #eef2ff, #e0e7ff);
  box-shadow: 0 2px 10px rgba(99,102,241,.15);
}
.ai-af-dim-card-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.ai-af-dim-card-name {
  font-size: 13px; font-weight: 600;
  color: #334155;
  flex: 1;
}
.ai-af-dim-card.checked .ai-af-dim-card-name {
  color: #4f46e5;
}

/* 隐藏原生checkbox */
.ai-af-dim-card-cb {
  position: absolute; opacity: 0; pointer-events: none;
}
/* 自定义勾选标记 */
.ai-af-dim-card-check {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  flex-shrink: 0;
  transition: all .18s ease;
  display: flex; align-items: center; justify-content: center;
}
.ai-af-dim-card.checked .ai-af-dim-card-check {
  background: #6366f1;
  border-color: #6366f1;
}
.ai-af-dim-card.checked .ai-af-dim-card-check::after {
  content: '✓';
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

/* 弹窗底部 */
.ai-af-dim-modal-footer {
  padding: 14px 24px;
  border-top: 1px solid #f1f5f9;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.ai-af-dim-btn {
  padding: 8px 18px;
  border-radius: 10px;
  border: none;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
}
.ai-af-dim-btn.primary {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,.35);
}
.ai-af-dim-btn.primary:hover {
  background: linear-gradient(135deg, #4f46e5, #6d28d9);
  box-shadow: 0 4px 14px rgba(99,102,241,.45);
  transform: translateY(-1px);
}
.ai-af-dim-btn.secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.ai-af-dim-btn.secondary:hover {
  background: #e2e8f0;
  color: #334155;
}
.ai-af-dim-btn.ghost {
  background: transparent;
  color: #94a3b8;
}
.ai-af-dim-btn.ghost:hover {
  color: #64748b;
  background: #f8fafc;
}

/* ── 脱敏开关 ── */
.ai-af-mask-btn {
  font-size: 12px !important;
}
.ai-af-mask-btn.active {
  background: rgba(34,197,94,.12) !important;
  color: #22c55e !important;
}

/* ── 脱敏标记 ── */
.ai-af-masked {
  background: rgba(0,0,0,.05);
  border-radius: 3px;
  padding: 0 4px;
  cursor: help;
  user-select: none;
  font-weight: 500;
}
.ai-af-shell.dark .ai-af-masked {
  background: rgba(255,255,255,.08);
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .ai-af-goodbad { grid-template-columns: 1fr; }
  .ai-af-header { padding: 10px 14px; }
  .ai-af-body { padding: 12px 14px; }
  .ai-af-followup { padding: 10px 14px; }
  .ai-af-hero-score { font-size: 36px; }
}

/* ── Dark Mode Extras ── */
.ai-af-shell.dark .ai-af-kpi-badge {
  background: rgba(99,102,241,.15);
  border-color: rgba(99,102,241,.3);
  color: #a5b4fc;
}
.ai-af-shell.dark .ai-af-expand-btn {
  background: rgba(99,102,241,.08);
  border-color: rgba(99,102,241,.2);
  color: #a5b4fc;
}
.ai-af-shell.dark .ai-af-expand-btn:hover {
  background: rgba(99,102,241,.15);
  border-color: #818cf8;
}
.ai-af-shell.dark .ai-af-segment-collapsed {
  mask-image: linear-gradient(to bottom, #e2e8f0 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #e2e8f0 60%, transparent 100%);
}
.ai-af-shell.dark .ai-af-segment-collapsed.expanded {
  mask-image: none;
  -webkit-mask-image: none;
}

/* ── Theme: Light (forced, for modal overlays) ── */
.ai-af-shell.theme-light {
  --card-bg: #ffffff;
  --bg: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  background: #ffffff;
  color: #1e293b;
}
