/* ===================================================================
   管理后台
   =================================================================== */

.admin {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------------- 顶栏 ---------------- */

.admin-top {
  height: var(--header-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}
.admin-top h1 { font-size: 15px; }
.admin-top .sub { font-size: 11.5px; color: var(--text-faint); }
.admin-top .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* ---------------- 内容区 ---------------- */

.admin-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tab-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.admin-panel { flex: 1; min-height: 0; overflow: auto; padding: 20px; }
.admin-panel.hidden { display: none; }

/* ---------------- 看板 ---------------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  padding: 16px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--brand);
}
.kpi.accent::after { background: var(--accent); }
.kpi.ok::after { background: var(--ok); }
.kpi.warn::after { background: var(--warn); }
.kpi-label { font-size: 12px; color: var(--text-soft); margin-bottom: 6px; }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.15; letter-spacing: -.5px; }
.kpi-value .unit { font-size: 14px; font-weight: 500; color: var(--text-faint); margin-left: 3px; }
.kpi-hint { margin-top: 5px; font-size: 11.5px; color: var(--text-faint); }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 14px;
}
.chart-card { padding: 16px 18px 18px; }
.chart-card h3 { font-size: 13.5px; margin-bottom: 14px; }
.chart-card .chart-sub { font-size: 11.5px; color: var(--text-faint); margin-top: -8px; margin-bottom: 14px; }

/* 横向条形图 */
.hbar { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 10px; }
.hbar-label { font-size: 12.5px; color: var(--text-soft); text-align: right; }
.hbar-track { height: 9px; border-radius: 6px; background: var(--bg-sunken); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 6px; transition: width .5s cubic-bezier(.3,.9,.3,1); }
.hbar-value { font-size: 12.5px; color: var(--text-faint); text-align: right; font-variant-numeric: tabular-nums; }

/* 柱状图 */
.vbars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 150px;
  padding-top: 8px;
}
.vbar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.vbar-track { width: 100%; flex: 1; display: flex; align-items: flex-end; }
.vbar-fill {
  width: 100%;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 72%, transparent));
  min-height: 3px;
  transition: height .5s cubic-bezier(.3,.9,.3,1);
}
.vbar-label {
  font-size: 10px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.vbar-value { font-size: 11px; color: var(--text-soft); font-variant-numeric: tabular-nums; }

/* 折线图 */
.line-chart { width: 100%; height: 168px; display: block; }
.line-chart .grid-line { stroke: var(--border); stroke-width: 1; }
.line-chart .axis-text { fill: var(--text-faint); font-size: 10px; }
.line-chart .area { fill: color-mix(in srgb, var(--brand) 14%, transparent); }
.line-chart .line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line-chart .dot { fill: var(--brand); }
.line-chart .dot-label { fill: var(--text-soft); font-size: 10px; text-anchor: middle; }

/* ---------------- 会话记录 ---------------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.filter-bar .input, .filter-bar .select { width: auto; min-width: 150px; }
.filter-bar .search { min-width: 240px; flex: 1; max-width: 380px; }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px;
  height: 100%;
}
@media (max-width: 1180px) {
  .split { grid-template-columns: 1fr; }
  .detail-pane { max-height: 560px; }
}

.list-pane { min-width: 0; overflow: auto; }
.detail-pane {
  min-width: 0;
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.detail-pane .placeholder { color: var(--text-faint); text-align: center; padding: 60px 12px; font-size: 13px; }

.transcript { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.t-item { display: flex; gap: 9px; }
.t-item.t-user { flex-direction: row-reverse; }
.t-avatar {
  width: 26px; height: 26px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 50%; font-size: 11px; font-weight: 600;
  background: var(--bg-sunken); color: var(--text-soft);
}
.t-item.t-user .t-avatar { background: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { .t-item.t-user .t-avatar { color: #14202b; } }
.t-item.t-bot .t-avatar { background: var(--brand-soft); color: var(--brand); }
.t-item.t-agent .t-avatar { background: var(--accent-soft); color: var(--accent); }
.t-body { max-width: 82%; }
.t-item.t-user .t-body { text-align: right; }
.t-bubble {
  padding: 8px 12px;
  border-radius: 11px;
  background: var(--bg-sunken);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}
.t-item.t-user .t-bubble { background: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { .t-item.t-user .t-bubble { color: #14202b; } }
.t-item.t-agent .t-bubble { background: var(--accent-soft); color: var(--accent); }
.t-meta { font-size: 10.5px; color: var(--text-faint); margin-top: 3px; }

.reply-box { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ---------------- 知识库 ---------------- */

.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.faq-card.off { opacity: .62; }
.faq-main { flex: 1; min-width: 0; }
.faq-q { font-size: 13.5px; font-weight: 600; margin-bottom: 5px; }
.faq-a { font-size: 13px; color: var(--text-soft); line-height: 1.65; white-space: pre-wrap; }
.faq-kw { margin-top: 7px; font-size: 11px; color: var(--text-faint); }
.faq-ops { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }

/* ---------------- 登录/认领页 ---------------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  background-image:
    radial-gradient(1000px 420px at 18% -10%, color-mix(in srgb, var(--brand) 13%, transparent), transparent 62%),
    radial-gradient(820px 380px at 85% 110%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%);
}
.gate-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px 26px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.gate-card .brand-mark { width: 44px; height: 44px; border-radius: 13px; font-size: 19px; margin: 0 auto 12px; }
.gate-card h2 { font-size: 18px; margin-bottom: 6px; }
.gate-card .desc { color: var(--text-soft); font-size: 12.5px; margin-bottom: 20px; }
.gate-card .field { text-align: left; }
.gate-err {
  margin-top: 12px; padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--accent);
  font-size: 12.5px; text-align: left;
}
.gate-note { margin-top: 14px; font-size: 11.5px; color: var(--text-faint); line-height: 1.7; }
