/* ===== KFF 客服系统 v2 · 视觉规范 =====
   蓝白轻玻璃 + 微信式交互（圆角方形头像 / 按住说话 / 气泡尾巴 / 时间分隔）
*/
:root{
  --brand:#2563eb; --brand-d:#1d4ed8; --brand-l:#60a5fa; --brand-50:#eff6ff;
  --ink:#0f172a; --ink-2:#334155; --muted:#7c8899; --line:#e6ebf2;
  --ok:#22c55e; --warn:#ef4444; --voice-bar:#94a3b8;
  --card:rgba(255,255,255,.86);
  --shadow-sm:0 1px 2px rgba(15,23,42,.05);
  --shadow:0 6px 20px rgba(15,23,42,.07);
  --shadow-lg:0 18px 44px rgba(15,23,42,.14);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%}
body{font:15px/1.55 -apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",Segoe UI,Roboto,sans-serif;
  color:var(--ink);background:linear-gradient(180deg,#eef5ff 0%,#f7fbff 42%,#fff 100%);
  -webkit-font-smoothing:antialiased}
button{font:inherit;cursor:pointer;border:0;background:none;color:inherit}
input,textarea,select{font:inherit;outline:none;color:inherit}
a{color:var(--brand);text-decoration:none}
::selection{background:#dbeafe}
/* 滚动条（桌面） */
::-webkit-scrollbar{width:9px;height:9px}
::-webkit-scrollbar-thumb{background:#cfdced;border-radius:9px}
::-webkit-scrollbar-track{background:transparent}

/* ---------------- 布局骨架 ---------------- */
.app{display:flex;flex-direction:column;height:100dvh;overflow:hidden}
.hd{flex:0 0 auto;display:flex;align-items:center;gap:11px;
  padding:calc(10px + env(safe-area-inset-top)) 13px 10px;
  background:rgba(255,255,255,.78);backdrop-filter:blur(16px) saturate(160%);
  -webkit-backdrop-filter:blur(16px) saturate(160%);
  border-bottom:1px solid rgba(226,232,240,.8);box-shadow:0 1px 0 rgba(255,255,255,.6) inset;z-index:6}
.hd .title{min-width:0}
.hn{font-weight:650;font-size:15.5px;letter-spacing:.2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  display:flex;align-items:center;gap:6px}
.hs{font-size:11.5px;color:var(--muted);margin-top:2px;display:flex;align-items:center;gap:5px}
.dot{width:6px;height:6px;border-radius:50%;background:var(--ok);box-shadow:0 0 0 3px rgba(34,197,94,.15);flex:0 0 auto}
.sp{flex:1}
/* 圆角方形头像（微信风） */
.av{width:40px;height:40px;border-radius:11px;flex:0 0 auto;overflow:hidden;
  background:linear-gradient(140deg,var(--brand-l),var(--brand));color:#fff;font-weight:650;font-size:15px;
  display:flex;align-items:center;justify-content:center;box-shadow:0 3px 10px rgba(37,99,235,.22)}
.av img{width:100%;height:100%;object-fit:cover;display:block}
.av.sm{width:34px;height:34px;border-radius:9px;font-size:13.5px;box-shadow:none}
.ib{border:1px solid var(--line);background:#fff;border-radius:11px;height:34px;padding:0 11px;font-size:12.5px;
  color:var(--ink-2);display:inline-flex;align-items:center;gap:5px;box-shadow:var(--shadow-sm);transition:.15s}
.ib:active{background:var(--brand-50);border-color:#c7d8fb}
.back{width:34px;height:34px;border-radius:11px;background:#fff;border:1px solid var(--line);font-size:17px;
  color:var(--ink-2);display:none;align-items:center;justify-content:center;box-shadow:var(--shadow-sm)}
.hdsub{font-size:11.5px;color:var(--muted);text-align:center;padding:6px 0 2px}

/* ---------------- 聊天区 ---------------- */
.scroll{flex:1 1 auto;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:14px 12px 6px}
.sep{text-align:center;margin:14px 0 12px}
.sep span{font-size:11px;color:#9aa7b8;background:rgba(255,255,255,.75);border:1px solid var(--line);
  border-radius:999px;padding:3px 10px}
.row{display:flex;margin-bottom:12px;align-items:flex-start;gap:9px;animation:pop .2s cubic-bezier(.2,.8,.3,1)}
.row.me{flex-direction:row-reverse}
@keyframes pop{from{opacity:0;transform:translateY(7px) scale(.98)}to{opacity:1;transform:none}}
.bubble{position:relative;max-width:min(74%,540px);padding:9px 13px;border-radius:12px;font-size:15px;
  line-height:1.55;word-break:break-word;white-space:pre-wrap}
.them .bubble{background:#fff;border:1px solid rgba(226,232,240,.95);border-top-left-radius:4px;
  box-shadow:0 2px 6px rgba(15,23,42,.05)}
.me .bubble{background:linear-gradient(140deg,#3b82f6,var(--brand));color:#fff;border-top-right-radius:4px;
  box-shadow:0 4px 14px rgba(37,99,235,.26)}
.bubble::after{content:"";position:absolute;top:9px;width:8px;height:8px;transform:rotate(45deg)}
.them .bubble::after{left:-4.5px;background:#fff;border-left:1px solid rgba(226,232,240,.95);
  border-bottom:1px solid rgba(226,232,240,.95)}
.me .bubble::after{right:-4.5px;background:#3b82f6}
.meta{font-size:10.5px;color:#9aa7b8;margin:3px 4px 0;white-space:nowrap;align-self:flex-end}
.meta .read{color:var(--brand);font-weight:600}
.bubble.img{padding:5px;background:#fff!important;border:1px solid var(--line)}
.me .bubble.img{border-color:#bfdbfe}
.bubble.img img{display:block;width:min(210px,58vw);border-radius:9px;cursor:zoom-in}
.bubble.voice{display:flex;align-items:center;gap:9px;padding:10px 13px;cursor:pointer}
.bubble.voice .mic{width:19px;height:19px;flex:0 0 auto}
.wv{display:flex;align-items:flex-end;gap:2.5px;height:15px}
.wv i{display:block;width:2.5px;border-radius:2px;background:var(--voice-bar);height:6px}
.me .bubble.voice .wv i{background:rgba(255,255,255,.85)}
.bubble.voice.playing .wv i{animation:wv .9s ease-in-out infinite}
.bubble.voice.playing .wv i:nth-child(2){animation-delay:.1s}.bubble.voice.playing .wv i:nth-child(3){animation-delay:.2s}
.bubble.voice.playing .wv i:nth-child(4){animation-delay:.3s}
@keyframes wv{0%,100%{height:5px}50%{height:15px}}
.vsec{font-size:12px;opacity:.9;flex:0 0 auto;font-variant-numeric:tabular-nums}
.sysline{text-align:center;font-size:11.5px;color:#9aa7b8;margin:12px 0}
.unreadbar{text-align:center;margin:8px 0 12px}
.unreadbar span{font-size:11px;color:#94a3b8;background:#fff;border:1px solid var(--line);border-radius:999px;padding:3px 10px}

/* ---------------- 输入区（微信式） ---------------- */
.ft{flex:0 0 auto;background:rgba(255,255,255,.9);backdrop-filter:blur(16px);
  border-top:1px solid rgba(226,232,240,.85);padding:8px 10px calc(8px + env(safe-area-inset-bottom))}
.inbar{display:flex;align-items:flex-end;gap:8px}
.icb{flex:0 0 auto;width:38px;height:40px;border-radius:11px;display:flex;align-items:center;justify-content:center;
  color:#5b6b80;font-size:20px;transition:.15s}
.icb:active{background:#eef4ff;color:var(--brand)}
.icb.on{color:var(--brand);background:#e8f0ff}
.icb svg,.ib svg,.rnd svg{width:21px;height:21px;display:block}
.back svg{width:18px;height:18px;display:block}
.av svg{width:20px;height:20px}
.icb.rnd,.rnd{flex:0 0 auto;width:38px;height:40px;border-radius:11px;display:flex;align-items:center;justify-content:center;
  color:#5b6b80;font-size:19px}
.rnd:active{background:#eef4ff;color:var(--brand)}
.txt{flex:1;min-height:40px;max-height:116px;padding:9px 13px;border:1.5px solid var(--line);border-radius:11px;
  font-size:16px;resize:none;background:#fff;line-height:1.45;transition:.15s}
.txt:focus{border-color:#a8c7fa;box-shadow:0 0 0 4px rgba(96,165,250,.12)}
.hold{flex:1;height:40px;border-radius:11px;background:#fff;border:1.5px solid var(--line);
  display:flex;align-items:center;justify-content:center;font-size:15px;font-weight:600;color:var(--ink-2);
  user-select:none;transition:.12s}
.hold.active{background:#e8f0ff;border-color:#a8c7fa;color:var(--brand-d);transform:scale(.99)}
.hold.cancel{background:#fee2e2;border-color:#fca5a5;color:#b91c1c}
.snd{flex:0 0 auto;min-width:60px;height:40px;padding:0 15px;border-radius:11px;color:#fff;font-size:14.5px;
  font-weight:650;background:linear-gradient(140deg,var(--brand-l),var(--brand));
  box-shadow:0 6px 16px rgba(37,99,235,.28);display:flex;align-items:center;justify-content:center;
  opacity:.45;pointer-events:none;transition:.15s}
.snd.on{opacity:1;pointer-events:auto}
.snd:active{transform:scale(.96)}
/* 按住说话：录制浮层 */
.recov{position:fixed;inset:0;z-index:300;display:none;align-items:center;justify-content:center;
  background:rgba(8,14,28,.28);backdrop-filter:blur(2px)}
.recov.on{display:flex}
.recbox{background:rgba(22,30,44,.94);border-radius:22px;padding:24px 30px;text-align:center;color:#fff;
  box-shadow:var(--shadow-lg);min-width:210px}
.recbox .big{width:56px;height:56px;margin:0 auto 14px;border-radius:50%;
  background:linear-gradient(140deg,#60a5fa,#2563eb);display:flex;align-items:center;justify-content:center}
.recbox .big svg{width:28px;height:28px}
.recbox .lv{display:flex;align-items:flex-end;justify-content:center;gap:3px;height:34px;margin-bottom:8px}
.recbox .lv i{width:4px;border-radius:3px;background:linear-gradient(180deg,#93c5fd,#3b82f6);animation:lv .8s ease-in-out infinite}
.recbox .lv i:nth-child(odd){animation-delay:.12s}.recbox .lv i:nth-child(3n){animation-delay:.26s}
@keyframes lv{0%,100%{height:7px}50%{height:28px}}
.recbox .t{font-size:22px;font-weight:650;font-variant-numeric:tabular-nums}
.recbox .h{font-size:12px;color:#b9c6d8;margin-top:6px}
.recbox.cancel .big{background:linear-gradient(140deg,#f87171,#dc2626)}
.recbox.cancel .h{color:#fca5a5}
/* 文字输入时的提示条 */
.typ{position:absolute;left:50%;transform:translateX(-50%);bottom:8px;font-size:11.5px;color:#94a3b8;
  background:rgba(255,255,255,.9);border:1px solid var(--line);border-radius:999px;padding:3px 10px;display:none}

/* ---------------- 会话列表 ---------------- */
.searchbar{padding:9px 12px;background:rgba(255,255,255,.7);border-bottom:1px solid rgba(226,232,240,.7)}
.searchbar input{width:100%;padding:9px 13px;border:1.5px solid var(--line);border-radius:11px;background:#fff;font-size:14.5px}
.conv{display:flex;gap:11px;padding:12px 14px;background:rgba(255,255,255,.62);align-items:center;
  border-bottom:1px solid rgba(226,232,240,.6);transition:.12s}
.conv:active{background:#eef4ff}
.cav{width:44px;height:44px;border-radius:12px;flex:0 0 auto;background:#e8eef7;color:#5b6b80;display:flex;
  align-items:center;justify-content:center;font-weight:650;font-size:16px;overflow:hidden;position:relative}
.cav img{width:100%;height:100%;object-fit:cover}
.cav .on{position:absolute;right:-2px;bottom:-2px;width:11px;height:11px;border-radius:50%;background:var(--ok);
  border:2px solid #fff}
.cmain{flex:1;min-width:0}
.ctop{display:flex;justify-content:space-between;align-items:baseline;gap:8px}
.cnm{font-weight:620;font-size:14.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:flex;align-items:center;gap:6px}
.cnm .from{font-size:11px;color:#94a3b8;font-weight:500}
.ctm{font-size:11px;color:#9aa7b8;flex:0 0 auto}
.clast{font-size:13px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:3px}
.badge{flex:0 0 auto;min-width:20px;height:20px;border-radius:10px;background:var(--warn);color:#fff;font-size:11px;
  font-weight:650;display:flex;align-items:center;justify-content:center;padding:0 6px;box-shadow:0 2px 8px rgba(239,68,68,.3)}
.empty{text-align:center;color:#9aa7b8;font-size:13.5px;padding:52px 26px;line-height:2}
.empty .big{font-size:38px;display:block;margin-bottom:8px;opacity:.75}

/* ---------------- 卡片/弹层 ---------------- */
.card{background:var(--card);backdrop-filter:blur(12px);border:1px solid rgba(226,232,240,.95);border-radius:18px;
  padding:18px;box-shadow:var(--shadow);margin-bottom:15px}
.card h3{margin:0 0 4px;font-size:16px}
.card p.sub{color:var(--muted);font-size:12.5px;margin:0 0 14px;line-height:1.7}
label{display:block;font-size:12.5px;color:var(--muted);margin-bottom:6px;font-weight:600}
input[type=text],input[type=password],input[type=search]{width:100%;padding:12px 14px;border:1.5px solid var(--line);
  border-radius:12px;font-size:16px;background:#fbfdff}
input:focus{border-color:#a8c7fa;box-shadow:0 0 0 4px rgba(96,165,250,.13)}
.primary{width:100%;margin-top:12px;padding:13px;color:#fff;font-size:15.5px;font-weight:650;border-radius:12px;
  background:linear-gradient(140deg,var(--brand-l),var(--brand));box-shadow:0 8px 20px rgba(37,99,235,.28)}
.primary:active{transform:scale(.985)}
.ghost{padding:9px 13px;border-radius:11px;background:var(--brand-50);color:var(--brand-d);border:1px solid #d3e2fd;
  font-size:12.5px;font-weight:600}
.danger{padding:9px 13px;border-radius:11px;background:#fef2f2;color:#b91c1c;border:1px solid #fecaca;font-size:12.5px;font-weight:600}
.modal{position:fixed;inset:0;background:rgba(15,23,42,.55);backdrop-filter:blur(3px);display:flex;align-items:center;
  justify-content:center;z-index:200;padding:20px}
.mcard{background:#fff;border-radius:20px;padding:22px;text-align:center;max-width:88vw;box-shadow:var(--shadow-lg)}
.mtitle{font-weight:650;margin-bottom:12px}
.qrimg{width:236px;height:236px;max-width:68vw;max-height:68vw;display:block;margin:0 auto;border-radius:10px}
.mlink{font-size:11px;color:var(--muted);word-break:break-all;margin:10px 0;font-family:ui-monospace,Menlo,monospace}
.mrow{display:flex;gap:8px;justify-content:center;flex-wrap:wrap}
.mbtn{padding:10px 16px;border-radius:12px;background:var(--brand-50);color:var(--brand-d);border:1px solid #d3e2fd;
  font-size:13px;font-weight:600}
.viewer{position:fixed;inset:0;background:rgba(0,0,0,.92);display:flex;align-items:center;justify-content:center;z-index:300;padding:14px}
.viewer img{max-width:100%;max-height:100%;border-radius:10px}
#toast{position:fixed;left:50%;bottom:84px;transform:translateX(-50%) translateY(18px);background:rgba(17,24,39,.94);
  color:#fff;padding:10px 18px;border-radius:12px;font-size:13.5px;opacity:0;transition:.25s;pointer-events:none;z-index:400}
#toast.on{opacity:1;transform:translateX(-50%) translateY(0)}

/* ---------------- 客服引导页（客户端首屏） ---------------- */
.hero{text-align:center;padding:30px 22px 22px}
.hero .av{width:70px;height:70px;border-radius:20px;margin:0 auto 14px;font-size:26px;box-shadow:0 10px 26px rgba(37,99,235,.26)}
.hero h2{margin:0 0 6px;font-size:19px;letter-spacing:.2px}
.hero p{margin:0;color:var(--muted);font-size:13px}
.feat{display:grid;grid-template-columns:repeat(3,1fr);gap:9px;margin:20px 0 4px}
.feat div{background:#fff;border:1px solid var(--line);border-radius:13px;padding:12px 6px;font-size:11.5px;color:var(--ink-2);
  box-shadow:var(--shadow-sm)}
.feat .ic{font-size:18px;display:block;margin-bottom:5px}

/* ---------------- 管理台 ---------------- */
.wrap{max-width:1120px;margin:0 auto;padding:calc(20px + env(safe-area-inset-top)) 16px calc(34px + env(safe-area-inset-bottom))}
.wrap h1{font-size:21px;margin:0 0 4px}
.wrap .lead{color:var(--muted);font-size:13px;margin-bottom:18px}
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(148px,1fr));gap:12px;margin-bottom:16px}
.kpi{background:var(--card);border:1px solid rgba(226,232,240,.95);border-radius:16px;padding:16px 18px;box-shadow:var(--shadow)}
.kpi .n{font-size:31px;font-weight:700;letter-spacing:-.6px;line-height:1.1;font-variant-numeric:tabular-nums}
.kpi .l{font-size:11.5px;color:var(--muted);margin-top:4px;letter-spacing:.3px}
.ag{border:1px solid var(--line);border-radius:16px;padding:15px;background:#fff;margin-bottom:12px;box-shadow:var(--shadow-sm)}
.ag .nm{font-weight:680;font-size:15.5px;display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.tag{font-size:11px;background:var(--brand-50);color:var(--brand-d);border-radius:999px;padding:2px 9px;font-weight:600}
.tag.red{background:#fee2e2;color:#b91c1c}
.lrow{display:flex;align-items:center;gap:8px;margin:8px 0}
.ltag{flex:0 0 auto;font-size:11.5px;font-weight:650;border-radius:8px;padding:4px 9px}
.ltag.c{background:#dcfce7;color:#15803d}
.ltag.s{background:var(--brand-50);color:var(--brand-d)}
.lurl{flex:1;min-width:0;font-size:11.5px;color:#475569;background:#f8fafc;border:1px solid var(--line);
  border-radius:9px;padding:8px 10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  font-family:ui-monospace,Menlo,monospace}
.grid2{display:grid;grid-template-columns:330px 1fr;gap:14px}
@media(max-width:860px){.grid2{grid-template-columns:1fr}}
.panel{background:#fff;border:1px solid var(--line);border-radius:16px;overflow:hidden;
  height:calc(100dvh - 240px);min-height:430px;display:flex;flex-direction:column;box-shadow:var(--shadow)}
.panel .ph{padding:11px 14px;border-bottom:1px solid var(--line);font-weight:620;font-size:13.5px;background:#fbfdff;
  display:flex;align-items:center;gap:8px;color:var(--ink-2)}
.panel .pb{flex:1;overflow-y:auto}
.panel .pb.scroll{padding:14px 12px}
.qchips{display:flex;flex-wrap:wrap;gap:6px;margin:8px 0}
.qchip{background:var(--brand-50);color:var(--brand-d);border:1px solid #d3e2fd;border-radius:999px;padding:5px 11px;font-size:12px}
.qchip span{margin-left:6px;color:#94a3b8;cursor:pointer}
