/* ─── 基础变量 ─────────────────────────────────────────────────────────────── */
:root {
  --green:       #10b981;
  --green-deep:  #059669;
  --green-dark:  #065f46;
  --green-light: #d1fae5;
  --green-pale:  #f0fdf9;
  --grad:        linear-gradient(135deg, #34d399 0%, #059669 100%);
  --ink:         #0f2e22;
  --ink-2:       #1e4d3a;
  --muted:       #5f8a78;
  --bg:          #f4fbf7;
  --card:        rgba(255, 255, 255, 0.88);
  --card-solid:  #ffffff;
  --line:        rgba(16, 185, 129, 0.18);
  --shadow:      0 4px 24px rgba(5, 150, 105, 0.10);
  --shadow-lg:   0 16px 48px rgba(5, 150, 105, 0.18);
  --radius:      14px;
  --radius-sm:   8px;
}

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

html { font-size: 15px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── 背景装饰 ─────────────────────────────────────────────────────────────── */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(16,185,129,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16,185,129,.05) 1px, transparent 1px);
  background-size: 40px 40px;
}

.bg-glow {
  position: fixed; border-radius: 50%; pointer-events: none; z-index: 0;
  filter: blur(80px); opacity: .18;
}
.glow-1 { width: 600px; height: 600px; background: #34d399; top: -200px; right: -100px; }
.glow-2 { width: 400px; height: 400px; background: #059669; bottom: -100px; left: -80px; }

/* 水印层 */
.watermark {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: .08;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='420' height='240'><text x='10' y='130' font-size='15' fill='%23059669' font-family='sans-serif' transform='rotate(-24 210 120)'>苏州南潮电子科技有限公司demo使用</text></svg>");
  background-repeat: repeat;
}

/* ─── 顶部栏 ───────────────────────────────────────────────────────────────── */
.topbar {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 62px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 12px rgba(5,150,105,.07);
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo svg { width: 36px; height: 36px; display: block; }
.brand-text h1 {
  font-size: 1.05rem; font-weight: 700; color: var(--ink);
  display: flex; align-items: center; gap: 8px; line-height: 1.2;
}
.tag {
  font-size: .65rem; font-weight: 600; letter-spacing: .04em;
  background: var(--grad); color: #fff;
  padding: 2px 7px; border-radius: 20px;
}
.brand-text p { font-size: .72rem; color: var(--muted); margin-top: 2px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.mock-badge {
  font-size: .68rem; padding: 3px 10px; border-radius: 20px;
  background: #fef3c7; color: #92400e; border: 1px solid #fcd34d;
  font-weight: 600;
}

/* 按钮 */
.ghost-btn, .primary-btn, .danger-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .82rem; font-weight: 600; cursor: pointer;
  border-radius: var(--radius-sm); transition: all .18s;
  border: none; outline: none; font-family: inherit;
}
.ghost-btn {
  padding: 7px 14px;
  background: var(--green-pale); color: var(--green-deep);
  border: 1px solid var(--line);
}
.ghost-btn:hover { background: var(--green-light); }
.ghost-btn.active { background: var(--grad); color: #fff; border-color: transparent; }
.ghost-btn.active .tts-wave { opacity: 1; }

.primary-btn {
  padding: 8px 16px;
  background: var(--grad); color: #fff;
  box-shadow: 0 2px 12px rgba(5,150,105,.28);
}
.primary-btn:hover { box-shadow: 0 4px 20px rgba(5,150,105,.4); transform: translateY(-1px); }
.primary-btn:active { transform: translateY(0); }

.danger-btn {
  width: 100%; padding: 10px;
  background: #fff; color: #dc2626;
  border: 1.5px solid #fca5a5;
  font-size: .85rem; margin-top: 12px;
}
.danger-btn:hover:not(:disabled) { background: #fef2f2; border-color: #f87171; }
.danger-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ─── 主体布局 ─────────────────────────────────────────────────────────────── */
.layout {
  position: relative; z-index: 5;
  display: flex; gap: 16px;
  flex: 1; overflow: hidden;
  padding: 16px 20px;
  max-height: calc(100vh - 62px - 44px);
}

/* ─── 侧边栏 ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: 260px; flex-shrink: 0;
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

/* 人设卡 */
.persona-card { overflow: hidden; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: .82rem; font-weight: 700; color: var(--ink); letter-spacing: .03em; }

.scene-tag {
  font-size: .65rem; padding: 2px 8px; border-radius: 20px;
  background: var(--green-light); color: var(--green-dark); font-weight: 600;
}

.persona-body { padding: 12px 16px; }

.persona-name {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.persona-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: #fff; font-weight: 700; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(5,150,105,.3);
}
.persona-name-text strong { display: block; font-size: .9rem; color: var(--ink); }
.persona-name-text span { font-size: .72rem; color: var(--muted); }

.persona-rows { display: flex; flex-direction: column; gap: 7px; }
.persona-row { display: flex; gap: 8px; font-size: .76rem; line-height: 1.45; }
.persona-row .label {
  flex-shrink: 0; width: 52px; color: var(--muted); font-weight: 600;
}
.persona-row .value { color: var(--ink-2); }

.persona-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.ptag {
  font-size: .66rem; padding: 2px 8px; border-radius: 20px;
  background: var(--green-pale); color: var(--green-deep);
  border: 1px solid var(--line); font-weight: 500;
}
.ptag.warn { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }

/* 骨架屏 */
.skeleton-line {
  height: 12px; border-radius: 6px; margin-bottom: 8px;
  background: linear-gradient(90deg, #e8f5ef 25%, #d1fae5 50%, #e8f5ef 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
.skeleton-line.short { width: 60%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* 任务卡 */
.task-card { padding: 14px 16px; }
.task-card h2 { font-size: .82rem; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.task-card p { font-size: .76rem; color: var(--ink-2); line-height: 1.6; margin-bottom: 8px; }
.task-card ul { padding-left: 16px; display: flex; flex-direction: column; gap: 4px; }
.task-card li { font-size: .74rem; color: var(--muted); line-height: 1.5; }
.task-note {
  margin-top: 10px; padding: 8px 10px;
  background: var(--green-pale); border-left: 3px solid var(--green);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .7rem; color: var(--green-dark); line-height: 1.5;
}

/* ─── 聊天面板 ─────────────────────────────────────────────────────────────── */
.chat-panel {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
}

.messages {
  flex: 1; overflow-y: auto; padding: 20px 20px 12px;
  display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

/* 消息气泡 */
.msg { display: flex; gap: 10px; align-items: flex-start; animation: fadeUp .25s ease; }
.msg.staff { flex-direction: row-reverse; }
.msg.system { justify-content: center; }

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

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
}
.msg.parent .msg-avatar { background: var(--green-light); color: var(--green-dark); }
.msg.staff  .msg-avatar { background: var(--grad); color: #fff; box-shadow: 0 2px 8px rgba(5,150,105,.3); }

.msg-bubble {
  max-width: 70%; padding: 10px 14px; border-radius: var(--radius);
  font-size: .88rem; line-height: 1.65; word-break: break-word;
}
.msg.parent .msg-bubble {
  background: var(--card-solid); color: var(--ink);
  border: 1px solid var(--line);
  border-top-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(5,150,105,.07);
}
.msg.staff .msg-bubble {
  background: var(--grad); color: #fff;
  border-top-right-radius: 4px;
  box-shadow: 0 2px 12px rgba(5,150,105,.25);
}

.msg-sender {
  font-size: .65rem; color: var(--muted); margin-bottom: 3px; font-weight: 600;
}
.msg.staff .msg-sender { text-align: right; }

.system-pill {
  font-size: .74rem; color: var(--green-deep);
  background: var(--green-pale); border: 1px solid var(--line);
  padding: 5px 14px; border-radius: 20px; text-align: center;
}

/* 打字指示器 */
.typing { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--green);
  animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity:.4; } 30% { transform: translateY(-5px); opacity:1; } }

/* ─── 语音提示条 ───────────────────────────────────────────────────────────── */
.listen-hint {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 20px; font-size: .78rem; color: var(--green-deep);
  background: var(--green-pale); border-top: 1px solid var(--line);
}
.listen-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #ef4444;
  animation: pulse-dot 1s infinite;
}
@keyframes pulse-dot { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:.5; transform:scale(.8); } }

/* ─── 输入栏 ───────────────────────────────────────────────────────────────── */
.input-bar {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(8px);
}

.mic-btn {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--green-pale); border: 1.5px solid var(--line);
  color: var(--green-deep); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s; position: relative;
}
.mic-btn:hover { background: var(--green-light); border-color: var(--green); }
.mic-btn.listening {
  background: var(--grad); color: #fff; border-color: transparent;
  box-shadow: 0 0 0 4px rgba(16,185,129,.2);
  animation: pulse-ring 1.5s infinite;
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,.4); }
  70%  { box-shadow: 0 0 0 10px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
.mic-btn:disabled { opacity: .4; cursor: not-allowed; }

#input {
  flex: 1; resize: none; border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 12px;
  font-size: .88rem; font-family: inherit; color: var(--ink);
  background: #fff; line-height: 1.5;
  max-height: 120px; transition: border-color .2s;
  overflow-y: auto;
}
#input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(16,185,129,.1); }
#input::placeholder { color: #a8c8b8; }

.send-btn {
  width: 38px; height: 38px; border-radius: var(--radius-sm); flex-shrink: 0;
  background: var(--grad); border: none; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(5,150,105,.3);
  transition: all .18s;
}
.send-btn:hover { box-shadow: 0 4px 16px rgba(5,150,105,.45); transform: translateY(-1px); }
.send-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ─── 页脚 ─────────────────────────────────────────────────────────────────── */
.footer {
  position: relative; z-index: 10;
  text-align: center; padding: 10px 20px;
  font-size: .7rem; color: var(--muted);
  background: rgba(255,255,255,.85);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

/* ─── 评估报告弹窗 ─────────────────────────────────────────────────────────── */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(6,95,70,.35); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}

.modal {
  background: #fff; border-radius: 20px;
  width: 100%; max-width: 680px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn .28s cubic-bezier(.34,1.56,.64,1);
  overflow: hidden;
}
@keyframes modalIn { from { opacity:0; transform:scale(.92) translateY(16px); } to { opacity:1; transform:scale(1) translateY(0); } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(209,250,229,.5), rgba(240,253,249,.5));
}
.modal-head h2 { font-size: 1.05rem; font-weight: 700; color: var(--ink); }

.deal-badge {
  font-size: .72rem; padding: 3px 12px; border-radius: 20px; font-weight: 700;
}
.deal-badge.closed { background: #d1fae5; color: #065f46; }
.deal-badge.lost   { background: #fee2e2; color: #991b1b; }
.deal-badge.none   { background: #f3f4f6; color: #6b7280; }

.report-loading {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 60px 24px;
}
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--green-light); border-top-color: var(--green-deep);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.report-loading p { font-size: .84rem; color: var(--muted); }

.report-body { overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 20px; }
.report-body::-webkit-scrollbar { width: 5px; }
.report-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.score-hero {
  display: flex; align-items: center; gap: 24px;
  padding: 20px; background: var(--green-pale);
  border-radius: var(--radius); border: 1px solid var(--line);
}
#radar { flex-shrink: 0; }

.score-right { flex: 1; min-width: 0; }
.score-num {
  font-size: 3rem; font-weight: 800; color: var(--green-deep); line-height: 1;
  display: flex; align-items: baseline; gap: 4px;
}
.score-num small { font-size: 1rem; font-weight: 500; color: var(--muted); }

.level-badge {
  display: inline-block; margin: 8px 0;
  font-size: .78rem; font-weight: 700; padding: 3px 14px; border-radius: 20px;
}
.level-badge.优秀  { background: #d1fae5; color: #065f46; }
.level-badge.良好  { background: #dbeafe; color: #1e40af; }
.level-badge.合格  { background: #fef3c7; color: #92400e; }
.level-badge.不合格 { background: #fee2e2; color: #991b1b; }

.summary-text { font-size: .82rem; color: var(--ink-2); line-height: 1.6; }

/* 维度分数条 */
.dim-list { display: flex; flex-direction: column; gap: 10px; }
.dim-row { display: flex; align-items: center; gap: 10px; }
.dim-label { width: 110px; font-size: .76rem; color: var(--muted); flex-shrink: 0; text-align: right; }
.dim-bar-wrap { flex: 1; height: 8px; background: var(--green-pale); border-radius: 4px; overflow: hidden; }
.dim-bar {
  height: 100%; border-radius: 4px;
  background: var(--grad);
  transition: width .8s cubic-bezier(.4,0,.2,1);
}
.dim-score { width: 42px; font-size: .78rem; font-weight: 700; color: var(--green-deep); text-align: right; flex-shrink: 0; }

/* 三列点评 */
.report-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.report-col {
  border-radius: var(--radius); padding: 14px;
  border: 1px solid var(--line);
}
.report-col.good { background: #f0fdf4; }
.report-col.bad  { background: #fff7ed; border-color: #fed7aa; }
.report-col.tip  { background: #eff6ff; border-color: #bfdbfe; }
.report-col h3 { font-size: .76rem; font-weight: 700; margin-bottom: 8px; }
.report-col.good h3 { color: #166534; }
.report-col.bad  h3 { color: #9a3412; }
.report-col.tip  h3 { color: #1e40af; }
.report-col ul { padding-left: 14px; display: flex; flex-direction: column; gap: 5px; }
.report-col li { font-size: .74rem; line-height: 1.55; color: var(--ink-2); }

.modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-top: 1px solid var(--line);
  background: #fafefc;
}
.modal-watermark { font-size: .66rem; color: rgba(5,150,105,.4); }
.modal-foot > div { display: flex; gap: 8px; }

/* ─── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: #fff; font-size: .82rem;
  padding: 9px 20px; border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  z-index: 200; opacity: 0; transition: all .25s;
  pointer-events: none; white-space: nowrap;
  max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── 工具类 ───────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── 响应式 ───────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .layout { flex-direction: column; padding: 10px; gap: 10px; max-height: none; }
  .sidebar { width: 100%; flex-direction: row; gap: 10px; overflow-x: auto; }
  .sidebar .card { min-width: 220px; }
  .chat-panel { min-height: 400px; }
  .report-cols { grid-template-columns: 1fr; }
  .score-hero { flex-direction: column; text-align: center; }
  .brand-text p { display: none; }
}
