:root {
  --brand: #2ba471;      /* 绿 */
  --brand-dark: #1f7d56;
  --accent: #ff8a3d;     /* 橙 */
  --accent-dark: #e96f1f;
  --bg: #f5f7f6;
  --card: #ffffff;
  --text: #1f2d27;
  --muted: #7c8a83;
  --border: #e6ebe8;
  --shadow: 0 6px 24px rgba(43,164,113,.10);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6;
}
a { color: var(--brand-dark); }

/* ===== 访客端聊天 ===== */
.cs-app { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--card); box-shadow: var(--shadow); }
.cs-header {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; padding: 16px 18px; display: flex; align-items: center; gap: 12px;
}
.cs-header .avatar { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.cs-header h1 { font-size: 16px; margin: 0; font-weight: 600; }
.cs-header p { font-size: 12px; margin: 2px 0 0; opacity: .85; }
.cs-status { margin-left: auto; font-size: 12px; background: rgba(255,255,255,.18); padding: 3px 10px; border-radius: 20px; }

.cs-chips { padding: 12px 14px 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: #eef6f1; color: var(--brand-dark); border: 1px solid #d6ebdf; padding: 6px 12px; border-radius: 20px; font-size: 13px; cursor: pointer; transition: .15s; }
.chip:hover { background: var(--brand); color: #fff; }

.cs-messages { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: 14px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: #f0f3f1; color: var(--text); border-bottom-left-radius: 4px; white-space: normal; }
.msg.bot .md-line { margin: 2px 0; }
.msg.bot .md-ul { margin: 4px 0 8px; padding-left: 20px; }
.msg.bot .md-ul li { margin: 3px 0; line-height: 1.5; }
.msg.bot strong { color: var(--brand-dark); font-weight: 700; }
.msg.bot.handoff { background: #fff4ec; border: 1px solid #ffd9bf; }
.msg .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.typing { align-self: flex-start; background: #f0f3f1; padding: 12px 16px; border-radius: 14px; }
.typing span { display: inline-block; width: 6px; height: 6px; margin: 0 2px; background: #b6c4bd; border-radius: 50%; animation: blink 1.2s infinite; }
.typing span:nth-child(2){ animation-delay: .2s; } .typing span:nth-child(3){ animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.3} 40%{opacity:1} }

.cs-input { border-top: 1px solid var(--border); padding: 12px 14px; display: flex; gap: 8px; align-items: flex-end; }
.cs-input textarea { flex: 1; resize: none; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font-size: 14px; font-family: inherit; max-height: 100px; outline: none; }
.cs-input textarea:focus { border-color: var(--brand); }
.btn { background: var(--accent); color: #fff; border: none; border-radius: 12px; padding: 10px 18px; font-size: 14px; cursor: pointer; font-weight: 600; }
.btn:hover { background: var(--accent-dark); }
.btn.ghost { background: #eef6f1; color: var(--brand-dark); }
.btn.full { width: 100%; }

/* 满意度弹层 */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 50; }
.overlay.show { display: flex; }
.modal { background: #fff; width: 320px; border-radius: 16px; padding: 22px; text-align: center; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.rate-row { display: flex; gap: 12px; justify-content: center; margin-bottom: 12px; }
.rate-btn { flex: 1; padding: 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; font-size: 14px; }
.rate-btn.good.sel { background: #eafaf1; border-color: var(--brand); color: var(--brand-dark); }
.rate-btn.bad.sel { background: #fff0f0; border-color: #ff6b6b; color: #d23d3d; }
.modal textarea { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 8px; font-family: inherit; font-size: 13px; resize: none; }

/* ===== 管理后台 ===== */
.admin-wrap { max-width: 1180px; margin: 0 auto; padding: 20px; }
.login-box { max-width: 360px; margin: 12vh auto; background: #fff; padding: 30px; border-radius: 16px; box-shadow: var(--shadow); }
.login-box h2 { margin: 0 0 6px; color: var(--brand-dark); }
.login-box p { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login-box input { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.admin-nav { background: #fff; border-radius: 14px; padding: 10px 14px; display: flex; gap: 8px; align-items: center; box-shadow: var(--shadow); margin-bottom: 18px; flex-wrap: wrap; }
.admin-nav .logo { font-weight: 700; color: var(--brand-dark); margin-right: 8px; }
.admin-nav a { padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 14px; color: var(--text); text-decoration: none; }
.admin-nav a.active { background: var(--brand); color: #fff; }
.admin-nav .spacer { flex: 1; }
.admin-nav .user { font-size: 13px; color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: #fff; border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--brand-dark); }
.stat-card .lbl { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat-card.orange .num { color: var(--accent-dark); }

.panel { background: #fff; border-radius: 14px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel h3 { margin: 0 0 14px; font-size: 15px; color: var(--brand-dark); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.filters .btn { padding: 7px 14px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; background: #fafbfa; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; background: #eef6f1; color: var(--brand-dark); }
.tag.ho { background: #fff4ec; color: var(--accent-dark); }
.tag.closed { background: #f0f3f1; color: var(--muted); }
.tag.bad { background: #ffeaea; color: #d23d3d; }
.tag.good { background: #eafaf1; color: var(--brand-dark); }
.clickable { color: var(--brand-dark); cursor: pointer; text-decoration: underline; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.bar-row .name { width: 110px; color: var(--muted); }
.bar-track { flex: 1; background: #eef2f0; border-radius: 8px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); }
.bar-row .val { width: 50px; text-align: right; color: var(--brand-dark); }

.miss-list li { margin-bottom: 6px; }
.hidden { display: none !important; }
.empty { color: var(--muted); text-align: center; padding: 30px; font-size: 14px; }
.view-msgs { max-height: 340px; overflow-y: auto; }
.view-msgs .msg { max-width: 100%; }
.row-actions select { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border); font-size: 12px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--brand-dark); color: #fff; padding: 10px 20px; border-radius: 24px; font-size: 14px; opacity: 0; transition: .3s; z-index: 99; }
.toast.show { opacity: 1; }

/* 转微信客服卡片 */
.msg.kf-card { max-width: 88%; background: #eafaf1; border: 1px solid #bfe6cf; align-self: flex-start; display: flex; flex-direction: column; gap: 10px; }
.kf-card .kf-title { font-weight: 700; color: var(--brand-dark); font-size: 14px; }
.kf-card .kf-btn { display: inline-block; background: var(--brand); color: #fff; text-align: center; padding: 10px 14px; border-radius: 10px; text-decoration: none; font-size: 14px; font-weight: 600; }
.kf-card .kf-btn:hover { background: var(--brand-dark); }
.kf-card .kf-qr { width: 150px; height: 150px; border-radius: 10px; border: 1px solid var(--border); align-self: center; }
.kf-card .kf-tip { font-size: 12px; color: var(--muted); text-align: center; }
