/* ============================================================
   小智 · 智能助教 Agent
   Design tokens
   ============================================================ */
:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.14);
  --bg: #eef1f7;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-ink: #312e81;
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius-lg: 24px;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-lg: 0 32px 80px -32px rgba(15, 23, 42, 0.35), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow: 0 8px 24px -12px rgba(15, 23, 42, 0.18);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --font: 'Inter', 'PingFang SC', 'HarmonyOS Sans SC', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 12% -10%, #e5e0ff 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #d8f0ff 0%, transparent 50%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.6;
}

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--brand); text-decoration: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.14); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, 0.24); }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   Chat page shell
   ============================================================ */
.app {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.shell {
  width: min(1200px, 100%);
  height: min(860px, calc(100vh - 56px));
  display: grid;
  grid-template-columns: 336px 1fr;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

/* ---------- Brand panel ---------- */
.brand-panel {
  position: relative;
  background: linear-gradient(160deg, #1e1b4b 0%, #312e81 52%, #4338ca 100%);
  color: #fff;
  padding: 30px 26px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow: hidden;
}
.brand-panel::before {
  content: '';
  position: absolute;
  width: 420px; height: 420px;
  right: -180px; top: -160px;
  background: radial-gradient(circle, rgba(129, 140, 248, 0.55), transparent 65%);
  filter: blur(6px);
}
.brand-panel::after {
  content: '';
  position: absolute;
  width: 320px; height: 320px;
  left: -140px; bottom: -140px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.3), transparent 65%);
}
.brand-panel > * { position: relative; z-index: 1; }

.brand-top { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 11px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
  backdrop-filter: blur(6px);
}
.brand-name { font-weight: 650; letter-spacing: 0.2px; font-size: 15px; }
.brand-sub { font-size: 11px; color: rgba(255, 255, 255, 0.55); letter-spacing: 0.16em; text-transform: uppercase; }

.agent-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
  backdrop-filter: blur(10px);
}
.orb {
  width: 46px; height: 46px; flex: none;
  border-radius: 50%;
  background: conic-gradient(from 140deg, #a5b4fc, #7dd3fc, #c4b5fd, #a5b4fc);
  display: grid; place-items: center;
  font-weight: 700; color: #1e1b4b; font-size: 16px;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.09), 0 8px 20px -6px rgba(0, 0, 0, 0.5);
}
.agent-meta strong { display: block; font-size: 15px; font-weight: 600; }
.agent-meta span { font-size: 12px; color: rgba(255, 255, 255, 0.62); display: flex; align-items: center; gap: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }

.panel-title {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45); margin-bottom: 10px;
}
.topic-list { display: flex; flex-direction: column; gap: 8px; }
.topic {
  text-align: left;
  width: 100%;
  padding: 11px 13px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  transition: 0.18s ease;
}
.topic:hover { background: rgba(255, 255, 255, 0.14); transform: translateX(2px); }
.topic .k {
  width: 22px; height: 22px; flex: none; border-radius: 7px;
  display: grid; place-items: center; font-size: 12px;
  background: rgba(255, 255, 255, 0.12);
}

.brand-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: auto; }
.stat-mini {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px; padding: 12px 14px;
}
.stat-mini b { display: block; font-size: 18px; font-weight: 620; }
.stat-mini span { font-size: 11px; color: rgba(255, 255, 255, 0.55); }

.panel-foot { font-size: 11px; color: rgba(255, 255, 255, 0.45); line-height: 1.7; }

/* ---------- Chat panel ---------- */
.chat-panel { display: flex; flex-direction: column; min-width: 0; background: var(--surface); }

.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
}
.head-title { font-weight: 620; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.head-sub { font-size: 12px; color: var(--muted); }
.head-actions { margin-left: auto; display: flex; gap: 6px; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  color: var(--muted); border: 1px solid transparent;
  transition: 0.16s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.icon-btn svg { width: 17px; height: 17px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 550;
  background: rgba(79, 70, 229, 0.09); color: var(--brand);
  border: 1px solid rgba(79, 70, 229, 0.16);
  white-space: nowrap;
}
.pill.subtle { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.pill.ok { background: rgba(16, 185, 129, 0.1); color: #047857; border-color: rgba(16, 185, 129, 0.2); }
.pill.warn { background: rgba(245, 158, 11, 0.12); color: #b45309; border-color: rgba(245, 158, 11, 0.24); }
.pill.danger { background: rgba(239, 68, 68, 0.1); color: #b91c1c; border-color: rgba(239, 68, 68, 0.2); }

.intent-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfbfe, #ffffff);
  font-size: 12px; color: var(--muted);
  overflow-x: auto;
}
.intent-bar::-webkit-scrollbar { height: 0; }
.intent-bar .label { color: var(--muted-2); }

/* ---------- Messages ---------- */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 22px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.msg { display: flex; gap: 10px; max-width: 84%; animation: fade-up 0.32s cubic-bezier(0.16, 1, 0.3, 1); }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.agent { max-width: 88%; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.avatar {
  width: 30px; height: 30px; flex: none; border-radius: 10px;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 650;
  background: linear-gradient(140deg, #eef2ff, #e0e7ff);
  color: var(--brand-ink);
  border: 1px solid rgba(79, 70, 229, 0.12);
}
.msg.user .avatar { background: linear-gradient(140deg, #312e81, #4f46e5); color: #fff; border: none; }
.msg.agent .avatar { background: linear-gradient(140deg, #d1fae5, #a7f3d0); color: #065f46; border-color: rgba(16, 185, 129, 0.2); }

.bubble-wrap { min-width: 0; }
.bubble {
  padding: 12px 15px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13.8px;
  line-height: 1.72;
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
}
.msg.user .bubble {
  background: linear-gradient(140deg, #4f46e5, #6d28d9);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 20px -10px rgba(79, 70, 229, 0.7);
}
.msg.agent .bubble { background: #f0fdf9; border-color: rgba(16, 185, 129, 0.18); color: #064e3b; }
.msg.agent .bubble .who { display: block; font-size: 11px; font-weight: 600; color: #0f766e; margin-bottom: 4px; letter-spacing: 0.04em; }

.msg-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 6px; font-size: 11px; color: var(--muted-2);
  flex-wrap: wrap;
}
.msg.user .msg-meta { justify-content: flex-end; }
.tag {
  padding: 1px 7px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 10.5px; color: var(--muted);
}
.tag.kb { background: rgba(59, 130, 246, 0.08); border-color: rgba(59, 130, 246, 0.18); color: #1d4ed8; }
.tag.llm { background: rgba(124, 58, 237, 0.08); border-color: rgba(124, 58, 237, 0.18); color: #6d28d9; }
.tag.warn { background: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.22); color: #b45309; }

.sys-line {
  align-self: center;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  padding: 5px 14px;
  border-radius: 99px;
  max-width: 90%;
  text-align: center;
}

.handoff-card {
  align-self: stretch;
  border: 1px solid rgba(245, 158, 11, 0.28);
  background: linear-gradient(140deg, #fffbeb, #fef3c7);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex; gap: 12px; align-items: flex-start;
  animation: fade-up 0.3s ease;
}
.handoff-card .ic {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: rgba(245, 158, 11, 0.18); color: #b45309;
  display: grid; place-items: center; font-size: 15px;
}
.handoff-card strong { display: block; font-size: 13px; color: #92400e; margin-bottom: 2px; }
.handoff-card p { margin: 0; font-size: 12.5px; color: #a16207; line-height: 1.6; }
.handoff-card .queue { margin-left: auto; font-size: 11px; color: #b45309; white-space: nowrap; }

.quick-replies { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 22px 10px; }
.qr {
  padding: 6px 12px; border-radius: 99px;
  background: #fff; border: 1px solid var(--line-strong);
  font-size: 12px; color: var(--ink-2);
  transition: 0.16s ease;
}
.qr:hover { border-color: var(--brand); color: var(--brand); background: rgba(79, 70, 229, 0.04); }

/* typing */
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--brand); opacity: 0.5;
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.cursor {
  display: inline-block; width: 6px; height: 14px;
  background: var(--brand); vertical-align: -2px;
  margin-left: 2px; border-radius: 2px;
  animation: blink-cursor 1s steps(2) infinite;
}
@keyframes blink-cursor { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }

/* ---------- Composer ---------- */
.composer-wrap {
  border-top: 1px solid var(--line);
  padding: 12px 18px 16px;
  background: #fff;
}
.composer {
  display: flex; align-items: flex-end; gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 10px 10px 10px 16px;
  background: var(--surface-2);
  transition: 0.18s ease;
}
.composer:focus-within {
  border-color: rgba(79, 70, 229, 0.45);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.08);
}
.composer textarea {
  flex: 1; border: none; outline: none; resize: none;
  background: transparent; max-height: 132px; min-height: 24px;
  line-height: 1.6; font-size: 13.8px; padding: 2px 0;
}
.send-btn {
  width: 38px; height: 38px; flex: none; border-radius: 12px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 8px 18px -8px rgba(79, 70, 229, 0.8);
  transition: 0.16s ease;
}
.send-btn:hover { transform: translateY(-1px); }
.send-btn:disabled { opacity: 0.4; transform: none; box-shadow: none; cursor: not-allowed; }
.send-btn svg { width: 17px; height: 17px; }

.composer-foot {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px; font-size: 11px; color: var(--muted-2);
}
.composer-foot .ghost {
  margin-left: auto; color: var(--muted); display: inline-flex; gap: 5px; align-items: center;
  padding: 3px 8px; border-radius: 8px;
}
.composer-foot .ghost:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- Drawer / modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: 0.22s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: min(400px, 92vw);
  background: #fff;
  box-shadow: -24px 0 60px -30px rgba(15, 23, 42, 0.5);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column;
}
.drawer.show { transform: none; }
.drawer-head {
  padding: 18px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.drawer-head h3 { margin: 0; font-size: 15px; font-weight: 620; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 16px; }

.hist-item {
  width: 100%; text-align: left;
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff;
  margin-bottom: 8px; transition: 0.16s ease;
}
.hist-item:hover { border-color: rgba(79, 70, 229, 0.35); background: rgba(79, 70, 229, 0.03); }
.hist-item.active { border-color: var(--brand); background: rgba(79, 70, 229, 0.05); }
.hist-item .row { display: flex; align-items: center; gap: 8px; }
.hist-item .preview {
  font-size: 12.5px; color: var(--muted); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.hist-item time { font-size: 11px; color: var(--muted-2); margin-left: auto; }

.modal {
  position: fixed; z-index: 62; left: 50%; top: 50%;
  transform: translate(-50%, -46%) scale(0.97);
  width: min(420px, 92vw);
  background: #fff; border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 24px; opacity: 0; pointer-events: none;
  transition: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.show { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal h3 { margin: 0 0 4px; font-size: 17px; font-weight: 650; }
.modal p.sub { margin: 0 0 18px; color: var(--muted); font-size: 12.5px; }

.stars { display: flex; gap: 8px; justify-content: center; margin: 6px 0 14px; }
.star {
  font-size: 30px; line-height: 1; color: #e2e8f0;
  transition: 0.14s ease;
}
.star.on { color: #fbbf24; transform: translateY(-1px); }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.input, .textarea, .select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface-2); outline: none; font-size: 13px;
  transition: 0.16s ease;
}
.input:focus, .textarea:focus, .select:focus { border-color: rgba(79, 70, 229, 0.5); background: #fff; box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08); }
.textarea { min-height: 76px; resize: vertical; line-height: 1.6; }

.btn {
  padding: 10px 16px; border-radius: 10px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff; font-size: 13px; font-weight: 550;
  box-shadow: 0 8px 18px -10px rgba(79, 70, 229, 0.9);
  transition: 0.16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.ghost { background: #fff; color: var(--ink-2); border: 1px solid var(--line-strong); box-shadow: none; }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); box-shadow: none; }
.btn-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* toast */
.toast-stack { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #0f172a; color: #fff; font-size: 12.5px;
  padding: 9px 16px; border-radius: 99px;
  box-shadow: var(--shadow);
  animation: toast-in 0.24s ease;
}
.toast.err { background: #b91c1c; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Admin
   ============================================================ */
.admin { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.side {
  background: #0b1120;
  color: #cbd5e1;
  padding: 22px 16px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.side .brand-top { margin-bottom: 18px; padding: 0 6px; }
.side .brand-logo { background: rgba(255, 255, 255, 0.08); }
.side .brand-name { color: #fff; }
.side .brand-sub { color: rgba(255, 255, 255, 0.4); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  color: #94a3b8; font-size: 13px; text-align: left; width: 100%;
  transition: 0.16s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #e2e8f0; }
.nav-item.active { background: linear-gradient(100deg, rgba(79, 70, 229, 0.9), rgba(124, 58, 237, 0.75)); color: #fff; font-weight: 550; box-shadow: 0 8px 20px -14px rgba(99, 102, 241, 1); }
.nav-item svg { width: 16px; height: 16px; flex: none; }
.nav-item .count {
  margin-left: auto; font-size: 11px; padding: 0 6px; border-radius: 99px;
  background: rgba(245, 158, 11, 0.18); color: #fbbf24;
}
.side-foot { margin-top: auto; font-size: 11px; color: #475569; padding: 0 6px; line-height: 1.7; }
.side-foot a { color: #94a3b8; }

.admin-main { padding: 26px 30px 48px; min-width: 0; }
.admin-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.admin-head h1 { margin: 0; font-size: 22px; font-weight: 680; letter-spacing: -0.01em; }
.admin-head p { margin: 0; color: var(--muted); font-size: 12.5px; }
.admin-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.kpi::after { content: ''; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: rgba(79, 70, 229, 0.05); }
.kpi .k-label { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .k-value { font-size: 26px; font-weight: 680; letter-spacing: -0.02em; margin-top: 6px; }
.kpi .k-value small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi .k-foot { font-size: 11px; color: var(--muted-2); margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; margin-bottom: 18px; }
.grid-2.even { grid-template-columns: 1fr 1fr; }
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 620; }
.card-head .hint { font-size: 11.5px; color: var(--muted-2); margin-left: auto; }

/* bar chart */
.chart-bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%; max-width: 40px; border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, #818cf8, #4f46e5);
  min-height: 3px; position: relative;
  transition: height 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.bar.alt { background: linear-gradient(180deg, #c4b5fd, #8b5cf6); }
.bar-col .v { font-size: 10.5px; color: var(--muted); }
.bar-col .d { font-size: 10.5px; color: var(--muted-2); }

/* rating bars */
.rate-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 12px; }
.rate-row .nm { width: 40px; color: var(--muted); }
.rate-track { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.rate-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #fbbf24, #f59e0b); transition: width 0.5s ease; }
.rate-row .num { width: 46px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.donut-wrap { display: flex; align-items: center; gap: 18px; }
.legend { display: flex; flex-direction: column; gap: 7px; font-size: 12px; min-width: 0; }
.legend .li { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
.legend .sw { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend .n { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

/* table */
.table-wrap { overflow-x: auto; margin: 0 -6px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.tbl th {
  text-align: left; font-weight: 550; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap; font-size: 11.5px;
}
table.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: 0.14s ease; cursor: pointer; }
table.tbl tbody tr:hover { background: rgba(79, 70, 229, 0.035); }
.tbl .who { display: flex; align-items: center; gap: 8px; }
.tbl .who .av { width: 26px; height: 26px; border-radius: 8px; background: #eef2ff; color: var(--brand-ink); display: grid; place-items: center; font-size: 11px; font-weight: 600; }
.tbl .clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.tbl .mono { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 11.5px; }

.empty { padding: 34px 10px; text-align: center; color: var(--muted-2); font-size: 12.5px; }

/* admin detail drawer */
.conv-detail { display: flex; flex-direction: column; height: 100%; }
.conv-meta { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: #fbfbfe; }
.detail-msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; background: #fafbfd; }
.detail-msgs .bubble { font-size: 12.8px; }
.reply-box { border-top: 1px solid var(--line); padding: 12px 16px; background: #fff; display: flex; gap: 8px; align-items: flex-end; }
.reply-box textarea {
  flex: 1; border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 9px 11px; resize: none; outline: none; font-size: 13px; min-height: 40px; max-height: 100px;
  background: var(--surface-2);
}
.reply-box textarea:focus { border-color: rgba(79, 70, 229, 0.5); background: #fff; }

.faq-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.faq-item .q { font-weight: 550; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.faq-item .a { font-size: 12.3px; color: var(--muted); margin-top: 5px; line-height: 1.65; }
.faq-item .foot { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: 11px; color: var(--muted-2); }
.faq-item .foot .sp { margin-left: auto; display: flex; gap: 6px; }
.link-btn { font-size: 11.5px; color: var(--brand); padding: 2px 6px; border-radius: 6px; }
.link-btn:hover { background: rgba(79, 70, 229, 0.08); }
.link-btn.red { color: var(--danger); }
.link-btn.red:hover { background: rgba(239, 68, 68, 0.08); }

.login-gate {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  background: #fff; border-radius: 22px; padding: 30px 28px;
  box-shadow: var(--shadow-lg); border: 1px solid rgba(255, 255, 255, 0.7);
}
.login-card .orb { width: 44px; height: 44px; margin-bottom: 16px; }
.login-card h1 { margin: 0 0 4px; font-size: 19px; font-weight: 660; }
.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 12.5px; }

.badge-mode {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; padding: 4px 10px; border-radius: 99px;
  background: rgba(16, 185, 129, 0.09); color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.18);
}
.badge-mode.off { background: rgba(100, 116, 139, 0.08); color: var(--muted); border-color: var(--line); }

.note {
  font-size: 11.5px; color: var(--muted); background: var(--surface-2);
  border: 1px dashed var(--line-strong); border-radius: 10px;
  padding: 9px 12px; line-height: 1.65;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 980px) {
  .app { padding: 0; }
  .shell {
    grid-template-columns: 1fr;
    height: 100vh; height: 100dvh;
    border-radius: 0; border: none;
    box-shadow: none;
  }
  .brand-panel { display: none; }
  .chat-head { padding: 12px 14px; }
  .messages { padding: 18px 14px 6px; }
  .msg { max-width: 92%; }
  .quick-replies { padding: 0 14px 8px; }
  .composer-wrap { padding: 10px 12px 12px; }
  .admin { grid-template-columns: 1fr; }
  .side {
    position: static; height: auto; flex-direction: row;
    overflow-x: auto; padding: 12px; gap: 6px; align-items: center;
  }
  .side .brand-top, .side .side-foot { display: none; }
  .nav-item { white-space: nowrap; width: auto; }
  .nav-item .count { display: none; }
  .admin-main { padding: 18px 16px 40px; }
  .grid-2, .grid-2.even { grid-template-columns: 1fr; }
  .drawer { width: 100vw; }
}

/* 正文里的链接（实训报告短链等）：点开新窗口 */
.bubble .msg-link,
.msg-bubble .msg-link {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
  word-break: break-all;
}
.bubble .msg-link:hover { color: var(--brand-2); }
.msg.user .bubble .msg-link { color: #e9e5ff; }
