:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.error { color: var(--red); min-height: 20px; font-size: 13px; }

/* ---------- 登录 ---------- */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 10px 30px rgba(17, 24, 39, .06);
}
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card p { margin: 0 0 20px; font-size: 13px; }
.login-card label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}
.login-card input {
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
}
.login-card button { width: 100%; margin-top: 6px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { font-weight: 600; letter-spacing: .3px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 56px;
  z-index: 19;
}
.tab {
  border: 0;
  background: transparent;
  padding: 9px 14px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--text); background: #f3f4f6; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 4px;
  background: var(--red);
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

main { padding: 20px; max-width: 1400px; margin: 0 auto; }
h2 { font-size: 15px; margin: 22px 0 10px; }

/* ---------- 卡片 ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card .k { font-size: 12px; color: var(--muted); }
.card .v { font-size: 26px; font-weight: 600; margin-top: 4px; letter-spacing: -.5px; }
.card .v.warn { color: var(--amber); }
.card .v.bad { color: var(--red); }

/* ---------- 表格 ---------- */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  background: #fafafa;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  position: sticky;
  top: 0;
}
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: 0; }
td.empty { text-align: center; color: var(--muted); padding: 36px; }

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid;
}
.pill.ready   { color: var(--green); border-color: #a7f3d0; background: #ecfdf5; }
.pill.uploaded{ color: var(--primary); border-color: #bfdbfe; background: #eff6ff; }
.pill.pending { color: var(--muted); border-color: var(--line); background: #f9fafb; }
.pill.failed  { color: var(--red); border-color: #fecaca; background: #fef2f2; }
.pill.out     { color: #7c3aed; border-color: #ddd6fe; background: #f5f3ff; }
.pill.in      { color: #0891b2; border-color: #a5f3fc; background: #ecfeff; }

/* ---------- 表单 ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.checkbox-inline input { margin: 0; }
input, select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
}
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.panel h2 { margin-top: 0; }

.token-box {
  margin-top: 12px;
  padding: 12px 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  word-break: break-all;
}
.token-box strong { display: block; margin-bottom: 6px; font-family: inherit; color: var(--amber); }
.copy-btn { margin-left: 8px; }

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 12px;
}

/* ---------- 播放器 ---------- */
.player-bar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 12px 32px rgba(17, 24, 39, .14);
  z-index: 40;
  max-width: calc(100vw - 40px);
}
.player-bar audio { height: 34px; max-width: 320px; }

/* ---------- Toast ---------- */.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: #111827;
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }

@media (max-width: 720px) {
  main { padding: 14px; }
  .tabs { padding: 8px 14px 0; overflow-x: auto; }
  .topbar { padding: 0 14px; }
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 80;
}
.modal-card {
  background: var(--panel);
  border-radius: 14px;
  width: min(880px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 15px; flex: 1; }
.modal-body { padding: 16px 18px; overflow: auto; }

.kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px 18px;
  margin-bottom: 6px;
}
.kv > div { display: flex; flex-direction: column; gap: 2px; }
.kv span { font-size: 12px; color: var(--muted); }
.kv b { font-weight: 600; font-size: 14px; }

.detail-audio { margin: 16px 0 4px; }
.detail-audio audio { width: 100%; }

h4 {
  font-size: 13px;
  margin: 20px 0 8px;
  color: var(--muted);
  font-weight: 600;
}

.transcript {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 320px;
  overflow: auto;
}
.transcript-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.7;
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.seg {
  display: flex;
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.6;
}
.seg:hover { background: #f9fafb; }
.seg:last-child { border-bottom: 0; }
.seg .ts {
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;
}

.alert-mini {
  border: 1px solid #fecaca;
  background: #fef2f2;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

/* ---------- 客户画像 ---------- */
.intent-box {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 16px;
}
.intent-score {
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1px;
}
.intent-meta { display: flex; flex-direction: column; gap: 4px; }
.intent-meta .level { font-size: 15px; font-weight: 600; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 12px;
}

.signal { padding: 8px 12px; border-left: 3px solid var(--line); margin-bottom: 8px; font-size: 13px; }
.signal.positive { border-left-color: var(--green); background: #f0fdf4; }
.signal.negative { border-left-color: var(--red); background: #fef2f2; }
.signal.neutral  { border-left-color: var(--line); background: #fafafa; }
.signal .ev { color: var(--muted); font-size: 12px; margin-top: 4px; }

.msg { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.msg-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 12px; }
.msg-body { font-size: 13px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }

.list-tight { margin: 4px 0 12px; padding-left: 18px; font-size: 13px; }
.list-tight li { margin: 3px 0; }

/* ---------- 团队看板 ---------- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bar-label { width: 96px; flex: 0 0 auto; color: var(--muted); }
.bar-track { flex: 1; height: 10px; background: #f3f4f6; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 6px; transition: width .3s; }
.bar-val { width: 52px; text-align: right; font-variant-numeric: tabular-nums; }

.bars.vertical {
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
  height: 150px;
  padding-top: 8px;
}
.vbar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
}
.vbar-col {
  width: 68%;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}
.vbar span { font-size: 11px; color: var(--muted); }

.lvl-A .bar-fill { background: var(--green); }
.lvl-B .bar-fill { background: var(--primary); }
.lvl-C .bar-fill { background: var(--amber); }
.lvl-D .bar-fill { background: var(--red); }
.lvl-none .bar-fill { background: #d1d5db; }

/* ---------- 面包屑 / 子标签 ---------- */
.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 14px;
}
.crumbs a { color: var(--primary); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { color: var(--muted); }

.subtabs {
  display: flex;
  gap: 6px;
  margin: 16px 0 12px;
  border-bottom: 1px solid var(--line);
}
.subtab {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subtab:hover { color: var(--text); }
.subtab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }


/* ---------- 话术建议 ---------- */
.script {
  background: #f9fafb;
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.qa {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.65;
}
.qa .q { color: var(--muted); margin-bottom: 5px; }
.qa .a { color: var(--text); }




