/* ==========================================================================
   管理后台样式
   ========================================================================== */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 15% -10%, #e8eeff 0%, transparent 60%),
    radial-gradient(800px 500px at 100% 100%, #e9f7f2 0%, transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 30px 28px;
  border: 1px solid var(--border);
}
.login-card .brand-row { margin-bottom: 20px; }
.login-card h2 { margin: 0 0 4px; font-size: 20px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }

.admin-app { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }

.anav {
  background: #14161f;
  color: #c8ccdb;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.anav .logo {
  display: flex; align-items: center; gap: 9px; padding: 4px 8px 18px;
}
.anav .logo .brand-logo { width: 30px; height: 30px; font-size: 14px; border-radius: 9px; }
.anav .logo b { color: #fff; font-size: 14px; font-weight: 600; }
.anav .logo small { display: block; color: #7d849c; font-size: 11px; font-weight: 400; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: 9px; cursor: pointer;
  font-size: 13.5px; border: none; background: transparent; color: #b6bccd;
  text-align: left; width: 100%; transition: .13s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.on { background: var(--primary); color: #fff; }
.nav-item .badge {
  margin-left: auto; background: #e5484d; color: #fff; font-size: 11px;
  border-radius: 999px; padding: 1px 7px; font-weight: 600;
}
.anav .grow { flex: 1; }
.nav-foot { border-top: 1px solid rgba(255, 255, 255, .09); padding-top: 10px; font-size: 12px; }

.amain { min-width: 0; display: flex; flex-direction: column; }
.ahead {
  padding: 18px 26px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 20;
}
.ahead h1 { margin: 0; font-size: 17px; font-weight: 650; }
.ahead .sub { font-size: 12.5px; color: var(--muted); }
.ahead .spacer { flex: 1; }

.page { padding: 22px 26px 60px; }
.page[hidden] { display: none; }

.warn-banner {
  margin: 0 26px 0; padding: 10px 14px; border-radius: 10px;
  background: var(--warn-soft); border: 1px solid #f6e2c0; color: #8a5a06;
  font-size: 13px; display: flex; align-items: center; gap: 10px;
}
.warn-banner .spacer { flex: 1; }

/* KPI */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.kpi {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow-sm);
}
.kpi .k-label { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.kpi .k-value { font-size: 25px; font-weight: 680; letter-spacing: -.5px; line-height: 1.2; }
.kpi .k-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi .k-foot { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.kpi.accent { background: linear-gradient(160deg, #2f5bff, #3f6dff); border-color: #2f5bff; }
.kpi.accent .k-label, .kpi.accent .k-foot { color: rgba(255, 255, 255, .78); }
.kpi.accent .k-value { color: #fff; }

.grid-cards { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 1080px) { .grid-cards { grid-template-columns: 1fr; } }

.panel {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.panel-head {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.panel-head h3 { margin: 0; font-size: 14px; font-weight: 640; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px; }

/* 趋势图 */
.trend-svg { width: 100%; height: 168px; display: block; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-top: 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }

/* 横向条 */
.hbar { margin-bottom: 11px; }
.hbar .top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.hbar .top b { font-weight: 600; }
.hbar .track { height: 8px; background: #f0f2f8; border-radius: 6px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 6px; transition: width .5s ease; }

/* 满意度分布 */
.vbars { display: flex; align-items: flex-end; gap: 10px; height: 132px; margin-top: 6px; }
.vbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.vbar .v { font-size: 12px; color: var(--text-2); font-weight: 600; }
.vbar .b { width: 100%; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, #6b8cff, #2f5bff); min-height: 3px; transition: height .5s ease; }
.vbar .l { font-size: 11.5px; color: var(--muted); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; font-size: 13px; }
table.dt th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--panel-2); position: sticky; top: 0;
}
table.dt td { padding: 11px 12px; border-bottom: 1px solid #f1f3f9; vertical-align: top; }
table.dt tr.clickable { cursor: pointer; }
table.dt tr.clickable:hover td { background: #fafbfe; }
table.dt .q { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.dt .q2 { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input { width: auto; min-width: 180px; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 12px 4px; font-size: 13px; color: var(--text-2); }

/* 抽屉 */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(16, 20, 34, .38); z-index: 700;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.drawer-mask.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(620px, 94vw);
  background: #fff; z-index: 701; box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .24s cubic-bezier(.3, .8, .3, 1);
  display: flex; flex-direction: column;
}
.drawer.on { transform: none; }
.drawer-head { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.drawer-head h3 { margin: 0; font-size: 15px; }
.drawer-head .spacer { flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }

.tt-row { margin-bottom: 14px; display: flex; gap: 9px; }
.tt-row.user { flex-direction: row-reverse; }
.tt-bubble { max-width: 82%; padding: 9px 12px; border-radius: 12px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.tt-row.user .tt-bubble { background: var(--primary); color: #fff; border-top-right-radius: 4px; }
.tt-row.assistant .tt-bubble { background: #f4f6fb; border-top-left-radius: 4px; }
.tt-row.system .tt-bubble { background: var(--warn-soft); color: #8a5a06; width: 100%; max-width: 100%; font-size: 12.5px; }
.tt-meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }

.gap-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px dashed var(--border); font-size: 13px;
}
.gap-item:last-child { border-bottom: none; }
.gap-item .cnt { flex: none; background: var(--danger-soft); color: var(--danger); border-radius: 6px; padding: 1px 7px; font-size: 11.5px; font-weight: 600; }
.gap-item .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }

.recent-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid #f1f3f9; cursor: pointer;
}
.recent-item:last-child { border-bottom: none; }
.recent-item:hover { background: #fafbfe; }
.recent-item .t { flex: 1; min-width: 0; }
.recent-item .t b { font-size: 13px; font-weight: 550; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item .t span { font-size: 11.5px; color: var(--muted); }

.preset-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.preset {
  border: 1px solid var(--border-strong); background: #fff; border-radius: 999px;
  padding: 5px 12px; font-size: 12.5px; cursor: pointer; color: var(--text-2);
}
.preset:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track2 {
  width: 38px; height: 22px; border-radius: 999px; background: #d5d9e6; position: relative; transition: .18s ease;
}
.switch .track2::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; transition: .18s ease; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .track2 { background: var(--primary); }
.switch input:checked + .track2::after { transform: translateX(16px); }

@media (max-width: 860px) {
  .admin-app { grid-template-columns: 1fr; }
  .anav { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 10px; }
  .anav .logo, .anav .grow, .nav-foot { display: none; }
  .nav-item { white-space: nowrap; width: auto; }
  .page { padding: 16px; }
  .ahead { padding: 14px 16px; }
}

/* 知识库条目 · 案例截图 */
.kb-img-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.kb-img-cell { position: relative; }
.kb-img-cell img {
  width: 84px; height: 84px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); cursor: zoom-in; background: #f6f7fb; display: block;
}
.kb-img-x {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px;
  border-radius: 50%; border: 1px solid var(--border-strong); background: #fff;
  color: var(--danger, #e5484d); font-size: 12px; line-height: 1; cursor: pointer; padding: 0;
}
.kb-img-x:hover { background: #fdeeee; }

/* 会话详情抽屉 · 消息图片 */
.tt-images { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tt-images img {
  width: 72px; height: 72px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); cursor: zoom-in; background: #f6f7fb; display: block;
}
