/* =========================================================
 * agent.css —— 客服后台（工作台 + 数据看板）
 * ========================================================= */

.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

/* =========================================================
 * 访问门禁（隔离控制）
 * ========================================================= */
.agent-gate {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(4,7,13,.86); backdrop-filter: blur(8px);
  animation: fadeIn .22s ease;
}
.ag-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 32px 30px; text-align: center;
  animation: pop .26s cubic-bezier(.22,1,.36,1);
}
.ag-logo {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 30px rgba(79,140,255,.34);
}
.ag-title { font-size: 18px; font-weight: 650; letter-spacing: .01em; }
.ag-sub { color: var(--muted); font-size: 13px; margin-top: 8px; line-height: 1.7; }
.ag-card .field { text-align: left; }
.ag-card .field label { text-align: left; }
.ag-foot { margin-top: 16px; font-size: 11.5px; color: var(--muted); line-height: 1.6; }

/* ---------- 顶部 ---------- */
.tabs { display: flex; gap: 4px; margin-left: 14px; background: var(--surface-2); padding: 3px; border-radius: 11px; }
.tab {
  position: relative; padding: 0 15px; height: 32px; border-radius: 8px;
  font-size: 13px; color: var(--text-2); font-weight: 500;
  display: flex; align-items: center; gap: 7px; transition: all .16s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-4); color: var(--text); box-shadow: var(--shadow-sm); }
.tab-badge {
  background: #ef4444; color: #fff; font-size: 10.5px; font-weight: 700;
  min-width: 17px; height: 17px; border-radius: 9px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
}

.me-chip {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 11px 0 5px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 13px; color: var(--text); transition: background .16s;
}
.me-chip:hover { background: var(--surface-3); }

/* ---------- 视图切换 ---------- */
.view { flex: 1; min-height: 0; display: none; }
.view.active { display: block; }

/* =========================================================
 * 工作台
 * ========================================================= */
.desk {
  height: 100%;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 288px;
}

/* ---- 左侧列表 ---- */
.pane-list {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line-soft);
  background: rgba(11,16,25,.5);
}
.list-head { flex: 0 0 auto; padding: 14px 14px 10px; border-bottom: 1px solid var(--line-soft); }
.list-title { display: flex; align-items: baseline; gap: 8px; font-weight: 620; font-size: 14px; margin-bottom: 11px; }
.list-title .mini { font-size: 11.5px; color: var(--muted); font-weight: 400; }

.search { position: relative; margin-bottom: 10px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input {
  width: 100%; height: 34px; padding: 0 11px 0 32px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; outline: none; font-size: 13px;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input::placeholder { color: #55677f; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 4px 9px; border-radius: 8px; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--text-2);
  transition: all .14s;
}
.chip b { font-weight: 700; opacity: .65; margin-left: 2px; }
.chip:hover { background: var(--surface-3); }
.chip.active { background: var(--accent-soft); border-color: rgba(79,140,255,.34); color: #9dc0ff; }

.list-body { flex: 1; min-height: 0; padding: 8px; }
.list-foot { flex: 0 0 auto; padding: 10px 12px 12px; border-top: 1px solid var(--line-soft); }

.sess {
  display: flex; gap: 10px; padding: 11px; border-radius: 12px;
  cursor: pointer; margin-bottom: 5px;
  border: 1px solid transparent; transition: background .14s, border-color .14s;
  position: relative;
}
.sess:hover { background: var(--surface-2); }
.sess.on { background: var(--accent-soft); border-color: rgba(79,140,255,.3); }
.sess.wait::before {
  content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px;
  background: var(--warn); border-radius: 0 3px 3px 0;
}
.sess-main { flex: 1; min-width: 0; }
.sess-r1 { display: flex; align-items: center; gap: 6px; }
.sess-r1 .nm { font-weight: 600; font-size: 13.5px; }
.sess-r2 {
  font-size: 12.5px; color: var(--text-2); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sess-r2 .tp { color: var(--accent-2); font-style: italic; }
.sess-r3 {
  display: flex; flex-wrap: wrap; gap: 9px; margin-top: 5px;
  font-size: 11px; color: var(--muted);
}
.sess-r3 .warn-t { color: #fcd34d; font-weight: 600; }
.claim-btn { margin-top: 9px; width: 100%; }

/* ---- 中间聊天 ---- */
.pane-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 11px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
  background: rgba(14,20,31,.6);
}
.ch-who { min-width: 0; }
.ch-who .nm { font-weight: 620; font-size: 14.5px; }
.ch-who .st { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.back-btn {
  display: none; width: 32px; height: 32px; border-radius: 9px;
  align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line-soft);
}

.quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 9px; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.q-item {
  flex: 0 0 auto; padding: 4px 10px; border-radius: 999px; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--text-2);
  transition: all .14s;
}
.q-item:hover { background: var(--accent-soft); border-color: rgba(79,140,255,.3); color: #9dc0ff; }

/* ---- 右侧信息 ---- */
.pane-info {
  border-left: 1px solid var(--line-soft);
  background: rgba(11,16,25,.5);
  min-height: 0; display: flex;
}
.info-inner { flex: 1; padding: 16px; min-height: 0; }
.info-empty { color: var(--muted); font-size: 12.5px; text-align: center; padding-top: 56px; }

.info-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 18px 14px; background: var(--surface-2);
  border: 1px solid var(--line-soft); border-radius: 14px; margin-bottom: 14px;
}
.ic-name { font-weight: 650; font-size: 15px; }
.ic-sub { font-size: 12px; color: var(--muted); font-family: var(--mono); }

.info-sec { margin-bottom: 16px; }
.is-k {
  font-size: 11px; color: var(--muted); font-weight: 650;
  letter-spacing: .08em; margin-bottom: 8px; text-transform: uppercase;
}
.is-demand {
  font-size: 12.5px; line-height: 1.68; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 10px; padding: 10px 12px; word-break: break-word;
}
.is-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 6px 0; font-size: 12.5px; border-bottom: 1px dashed var(--line-soft);
}
.is-row:last-child { border-bottom: none; }
.is-row span { color: var(--muted); }
.is-row b { font-weight: 550; color: var(--text-2); text-align: right; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sg {
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 10px; padding: 10px 6px; text-align: center;
}
.sg b { display: block; font-size: 17px; font-weight: 700; color: var(--text); }
.sg span { font-size: 11px; color: var(--muted); }

.is-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px;
  background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--text-2);
  cursor: default;
}

/* =========================================================
 * 数据看板
 * ========================================================= */
.dash { height: 100%; padding: 22px 24px 34px; }
.dash-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.dash-title { font-size: 21px; font-weight: 660; letter-spacing: .01em; }
.dash-sub { font-size: 13px; color: var(--muted); margin-top: 5px; }

.team-switch { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 12px; border: 1px solid var(--line-soft); }
.tsw {
  display: flex; align-items: center; gap: 7px;
  padding: 0 15px; height: 34px; border-radius: 9px;
  font-size: 13px; color: var(--text-2); font-weight: 500; transition: all .16s;
}
.tsw i { font-style: normal; opacity: .7; }
.tsw:hover { color: var(--text); }
.tsw.on {
  background: linear-gradient(135deg, #3f7bf0, #5b96ff); color: #fff;
  box-shadow: 0 5px 16px rgba(79,140,255,.3);
}
.tsw.on i { opacity: 1; }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 306px;
  gap: 16px;
  align-items: start;
}

.card {
  background: rgba(14,20,31,.82); border: 1px solid var(--line);
  border-radius: 16px; padding: 18px;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 6px; flex-wrap: wrap; }
.card-title { font-size: 15px; font-weight: 620; }
.card-desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; max-width: 460px; line-height: 1.6; }

.series-legend { display: flex; gap: 14px; align-items: center; }
.sl { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); }
.sl-dash {
  width: 22px; height: 0; display: block;
  border-top: 2px dashed rgba(226,236,252,.85);
}
.sl-fill {
  width: 20px; height: 11px; display: block; border-radius: 3px;
  background: linear-gradient(135deg, rgba(79,140,255,.5), rgba(34,211,238,.3));
  border: 1.6px solid rgba(96,165,250,.95);
}

/* 雷达图 */
.radar-host { position: relative; width: 100%; height: 440px; margin-top: 6px; }
.radar-tip {
  position: absolute; z-index: 5; pointer-events: none;
  background: rgba(12,18,28,.97); border: 1px solid var(--line);
  border-radius: 11px; padding: 10px 12px; min-width: 150px;
  box-shadow: var(--shadow); backdrop-filter: blur(6px);
}
.rt-h { font-size: 13px; font-weight: 650; margin-bottom: 7px; }
.rt-r { display: flex; justify-content: space-between; gap: 16px; font-size: 12px; padding: 2px 0; }
.rt-r span { color: var(--muted); }
.rt-r b { font-weight: 650; font-variant-numeric: tabular-nums; }
.rt-t { margin-top: 7px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; text-align: center; }

/* 图例 */
.legend {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 14px; border-top: 1px dashed var(--line);
}
.lg-title { font-size: 11.5px; color: var(--muted); font-weight: 650; letter-spacing: .06em; margin-right: 2px; }
.lg-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px; border: 1px solid transparent;
  font-size: 12px;
}
.lg-item i { width: 9px; height: 9px; border-radius: 50%; display: block; }
.lg-item b { font-weight: 650; }
.lg-item em { font-style: normal; color: var(--muted); font-size: 11.5px; }

/* 侧栏 */
.card-side { display: flex; flex-direction: column; gap: 18px; }
.side-block { }
.side-k {
  font-size: 11px; color: var(--muted); font-weight: 650;
  letter-spacing: .08em; margin-bottom: 10px; text-transform: uppercase;
}
.side-note { font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 10px; line-height: 1.7; }
.side-note b { color: var(--text-2); font-weight: 650; }

.ring-wrap { position: relative; width: 148px; margin: 0 auto; }
.ring { width: 148px; height: 148px; display: block; }
.ring circle { transition: stroke-dashoffset .9s cubic-bezier(.22,1,.36,1), stroke .3s; }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
}
.ring-v { font-size: 25px; font-weight: 720; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.ring-t { font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }

.kpi { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 13px; }
.kpi-best { border-left: 3px solid var(--ok); }
.kpi-worst { border-left: 3px solid var(--bad); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-name { font-size: 13.5px; font-weight: 620; }
.kpi-v { font-size: 22px; font-weight: 720; margin: 5px 0 3px; font-variant-numeric: tabular-nums; }
.kpi-d { font-size: 11.5px; color: var(--muted); line-height: 1.6; }
.kpi-d b { color: var(--text-2); font-weight: 650; }

.trend { background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px 13px; }
.tr-v { font-size: 23px; font-weight: 720; font-variant-numeric: tabular-nums; }
.tr-d { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.6; }

.spark { display: flex; align-items: flex-end; gap: 6px; margin-top: 11px; height: 66px; }
.sp { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; height: 100%; }
.sp-bar { width: 100%; max-width: 26px; border-radius: 4px 4px 2px 2px; transition: height .5s cubic-bezier(.22,1,.36,1); }
.sp-bar.up { background: linear-gradient(180deg, #34d399, rgba(52,211,153,.3)); }
.sp-bar.dn { background: linear-gradient(180deg, #f87171, rgba(248,113,113,.3)); }
.sp span { font-size: 10px; color: var(--muted); white-space: nowrap; }

.dist-row { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; font-size: 12px; }
.dl { display: flex; align-items: center; gap: 6px; width: 52px; flex: 0 0 auto; font-weight: 600; }
.dl i { width: 8px; height: 8px; border-radius: 50%; display: block; }
.db { flex: 1; height: 7px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.db div { height: 100%; border-radius: 4px; transition: width .6s cubic-bezier(.22,1,.36,1); }
.dist-row b { width: 16px; text-align: right; font-variant-numeric: tabular-nums; }

/* 明细表 */
.card-table { grid-column: 1 / -1; }
.table-wrap { overflow-x: auto; margin-top: 12px; }
.dim-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 620px; }
.dim-table th {
  text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 650;
  letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.dim-table td { padding: 10px; border-bottom: 1px solid var(--line-soft); }
.dim-table tr:last-child td { border-bottom: none; }
.dim-table tbody tr:hover { background: rgba(255,255,255,.022); }
.td-dim { font-weight: 600; white-space: nowrap; }
.dim-table .num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.col-bar { width: 190px; }
.bar { position: relative; height: 8px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.bar-in { height: 100%; border-radius: 5px; transition: width .7s cubic-bezier(.22,1,.36,1); }
/* 目标线：进度条量程 0~120%，100% 落在 83.33% 处 */
.bar-mark {
  position: absolute; left: 83.33%; top: -2px; bottom: -2px; width: 2px;
  background: rgba(226,236,252,.72); border-radius: 2px;
}

/* 昵称预设 */
.preset { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }
.preset-item {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 11px 4px 4px; border-radius: 999px; font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--text-2);
  transition: all .14s;
}
.preset-item:hover { background: var(--accent-soft); border-color: rgba(79,140,255,.3); color: #9dc0ff; }

/* =========================================================
 * 响应式
 * ========================================================= */
@media (max-width: 1280px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr) 272px; }
  .radar-host { height: 400px; }
}

/* 平板：隐藏右侧信息栏，改为叠加抽屉 */
@media (max-width: 1120px) {
  .desk { grid-template-columns: 288px minmax(0, 1fr); }
  .pane-info {
    position: fixed; top: var(--header-h); right: 0; bottom: 0; width: 300px;
    background: rgba(11,16,25,.98); z-index: 40;
    transform: translateX(100%); transition: transform .26s cubic-bezier(.22,1,.36,1);
    box-shadow: -18px 0 44px rgba(0,0,0,.42);
  }
  body.show-info .pane-info { transform: none; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .card-side {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px; align-items: start;
  }
  .ring-wrap { width: 128px; }
  .ring { width: 128px; height: 128px; }
}

@media (max-width: 900px) {
  .dash { padding: 16px 14px 28px; }
  .radar-host { height: 360px; }
  .team-switch { width: 100%; }
  .tsw { flex: 1; justify-content: center; padding: 0 8px; }
}

/* 手机：列表与聊天互斥显示 */
@media (max-width: 720px) {
  :root { --header-h: 54px; }
  .topbar { padding: 0 11px; gap: 8px; }
  .brand span:last-child { display: none; }
  .conn { display: none; }
  .me-chip span:not(.avatar) { display: none; }
  .me-chip { padding: 0 6px; }
  .tabs { margin-left: 4px; }
  .tab { padding: 0 11px; font-size: 12.5px; }

  .desk { grid-template-columns: 1fr; position: relative; }
  .pane-list { border-right: none; }
  .pane-chat {
    position: absolute; inset: 0; z-index: 20;
    background: var(--bg); transform: translateX(100%);
    transition: transform .24s cubic-bezier(.22,1,.36,1);
  }
  body.mobile-chat .pane-chat { transform: none; }
  .back-btn { display: flex; }
  .pane-info { width: 100%; top: 0; z-index: 60; }
  body.show-info .pane-info { transform: none; }

  .radar-host { height: 320px; }
  .card { padding: 14px; border-radius: 14px; }
  .dash-title { font-size: 18px; }
  .legend { gap: 7px; }
  .lg-item em { display: none; }
  .msg-col { max-width: 84%; }
}

@media (max-width: 420px) {
  .radar-host { height: 288px; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
}
