/* 私域会员管理 Agent · 运营工作台视觉系统 */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f9fafc;
  --surface-tint: #eef6f5;
  --line: #dde4ee;
  --line-strong: #c9d3e2;

  --ink: #172033;
  --ink-soft: #536174;
  --ink-muted: #7b8796;
  --ink-faint: #a3adbb;

  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #d8efec;
  --accent-line: #9fd2cb;

  --info: #3157a4;
  --info-soft: #e4ebfb;
  --ok: #16794c;
  --ok-soft: #e0f2e8;
  --warn: #a16207;
  --warn-soft: #fff3d6;
  --danger: #b42318;
  --danger-soft: #fee7e4;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-panel: 0 14px 34px rgba(16, 24, 40, 0.08);

  --font-display: "Outfit", "Noto Sans SC", sans-serif;
  --font-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --sidebar-w: 236px;
  --topbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(238, 246, 245, 0.72) 0, rgba(245, 247, 251, 0) 240px),
    var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { appearance: none; }

.ambient { display: none; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.glass-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* 侧边栏 */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  background: #ffffff;
  box-shadow: none;
  z-index: 3;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
}
.brand-logo svg { width: 18px; height: 18px; }

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.brand-text strong {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.brand-text span {
  font-size: 11px;
  color: var(--ink-muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}
.nav-item .ico {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  color: var(--ink-muted);
  flex-shrink: 0;
}
.nav-item .ico svg { width: 17px; height: 17px; }
.nav-item:hover {
  background: var(--surface-soft);
  color: var(--ink);
}
.nav-item.active {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.nav-item.active .ico { color: var(--accent-strong); }

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 10px 4px;
  color: var(--ink-muted);
  font-size: 11px;
}
.version-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}

/* 主布局 */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  box-shadow: none;
}
.topbar-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-title {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--ink);
}
.page-subtitle {
  font-size: 12px;
  color: var(--ink-muted);
}

.status-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
}
.pill-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #b8e3cb;
}
.pill-off {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fac5bf;
}
.pill-muted {
  color: var(--ink-muted);
  background: var(--surface-soft);
}

.content {
  flex: 1;
  min-width: 0;
  padding: 22px 28px 34px;
  overflow: auto;
}

.page-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Agent 指挥台：真正的对话窗口（头部固定 + 消息区滚动 + 输入区固定），与企微会话工作台同款结构 */
.agent-console {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 14px;
  height: calc(100vh - var(--topbar-h) - 44px);
  min-height: 640px;
}
.agent-chat-panel {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.agent-drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(238, 246, 245, 0.92);
  backdrop-filter: blur(2px);
  border-radius: var(--radius);
  pointer-events: none;
}
.agent-drop-overlay[hidden] { display: none; }
.agent-drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 34px 48px;
  border: 2px dashed var(--accent-line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.85);
  color: var(--accent-strong);
  text-align: center;
}
.agent-drop-inner svg {
  width: 34px;
  height: 34px;
  animation: agent-drop-bounce 1.1s ease-in-out infinite;
}
.agent-drop-inner strong { font-size: 15px; }
.agent-drop-inner span {
  color: var(--ink-muted);
  font-size: 12px;
}
@keyframes agent-drop-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.agent-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(49, 87, 164, 0.06)),
    #fff;
}
.agent-chat-head h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}
.agent-chat-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.agent-kicker {
  margin-bottom: 2px;
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}
.agent-composer {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.agent-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.agent-quick {
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.agent-quick:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.agent-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
#agent-command {
  flex: 1;
  min-height: 48px;
  max-height: 200px;
  resize: vertical;
  border-color: #b8c8db;
  background: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#agent-command:focus {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.agent-input-row .btn {
  flex: none;
  height: 44px;
  padding: 0 22px;
}
.agent-attach-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.agent-attach-btn:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.agent-attach-btn svg { width: 18px; height: 18px; }
.agent-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  margin-bottom: 8px;
  padding: 6px 10px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12.5px;
  font-weight: 700;
}
.agent-attach-chip[hidden] { display: none; }
.agent-attach-chip svg { flex: none; width: 14px; height: 14px; }
.agent-attach-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-attach-size {
  flex: none;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 400;
}
.agent-attach-remove {
  flex: none;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.agent-attach-remove:hover {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
}
.thread-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  margin-bottom: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 12px;
  font-weight: 700;
}
.thread-file-chip svg { flex: none; width: 13px; height: 13px; }
.thread-file-chip span:first-of-type {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-file-chip .mono {
  flex: none;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.8;
}
.agent-typing-bubble { min-width: 120px; }
.agent-typing {
  display: flex;
  gap: 5px;
  padding: 6px 2px 2px;
}
.agent-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-muted);
  animation: agent-typing-dot 1.2s ease-in-out infinite;
}
.agent-typing span:nth-child(2) { animation-delay: 0.15s; }
.agent-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes agent-typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-4px); opacity: 1; }
}
.agent-command-hint {
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.agent-side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.agent-side-block {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.agent-side-queue {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.agent-side-queue .agent-action-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}
.section-head-mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.section-head-mini .side-title { margin-bottom: 0; }

.agent-context-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.agent-context-card {
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.agent-context-card span,
.agent-context-card em {
  display: block;
  color: var(--ink-muted);
  font-size: 12px;
  font-style: normal;
}
.agent-context-card strong {
  display: block;
  margin: 4px 0 2px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.1;
}

.agent-plan {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 16px 18px;
  background: #fbfcfe;
}
.agent-plan-note {
  margin: 0;
  padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink-muted);
  font-size: 12.5px;
  line-height: 1.6;
  max-width: 640px;
}
.agent-plan .thread-row { display: flex; }
.agent-plan .thread-row.employee { justify-content: flex-end; }
.agent-plan .thread-row.agent { justify-content: flex-start; }
.agent-plan .thread-bubble { max-width: 88%; }
.agent-plan .thread-row.agent.err .thread-bubble {
  border-color: var(--danger);
  background: rgba(220, 38, 38, 0.06);
}
.agent-plan-extra {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
}
.agent-plan-extra .agent-run-plan { margin: 0; }
.agent-plan-extra .agent-run-plan + .agent-action-panel,
.agent-plan-extra .agent-run-plan + .agent-trace-section,
.agent-plan-extra .agent-action-panel + .agent-trace-section { margin-top: 10px; }
.agent-run-summary {
  grid-column: 1 / -1;
  margin-bottom: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.agent-run-summary p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.5;
}
.agent-run-plan {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 13px;
}
.agent-step {
  min-height: 118px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.agent-step-index {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}
.agent-step strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
}
.agent-step p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 12.5px;
}
.agent-step.done {
  border-color: #b8e3cb;
  background: var(--ok-soft);
}
.agent-step.done .agent-step-index {
  background: var(--ok);
  color: #fff;
}
.agent-step.active {
  border-color: var(--accent-line);
  box-shadow: inset 3px 0 0 var(--accent);
}
.agent-step.active .agent-step-index {
  background: var(--accent);
  color: #fff;
}

.agent-action-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agent-action-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.agent-action-main { min-width: 0; }
.agent-action-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.agent-action-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-action-main p {
  margin: 3px 0 0;
  color: var(--ink-muted);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 面板与网格 */
.card,
.section-card,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card,
.section-card {
  padding: 18px;
  margin-bottom: 16px;
}
.card h2,
.section-card h2 {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 700;
}
.section-card h2:not(:first-child) {
  margin-top: 18px;
}
.card .sub,
.section-card .sub,
.sub {
  color: var(--ink-muted);
  font-size: 12.5px;
  margin: 0 0 14px;
}

.section-head,
.pane-head,
.thread-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.section-head h2,
.pane-head h2,
.thread-head h2 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
}
.section-card > .result-list,
.section-card > .field + .result-list,
.section-card > .btn + .result-list {
  margin-top: 14px;
}

.grid-2,
.module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.dash-grid,
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.settings-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-layout .section-card {
  margin-bottom: 0;
}
.settings-row {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr) minmax(128px, max-content);
  gap: 14px;
  align-items: start;
  padding: 16px 18px;
}
.settings-status-row {
  padding: 16px 18px 18px;
}
.settings-copy {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.settings-copy h2 {
  margin: 0 0 4px;
}
.settings-copy .sub {
  margin-bottom: 0;
}
.settings-icon {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  margin-top: 1px;
}
.settings-icon svg { width: 16px; height: 16px; }
.settings-copy-text { min-width: 0; }
.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px 12px;
  min-width: 0;
}
.settings-form-grid .field {
  margin-bottom: 0;
}
.settings-form-grid .hint {
  grid-column: 1 / -1;
  margin-top: 0;
}
.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  min-width: 136px;
}
.settings-actions .btn {
  width: 100%;
}

/* 分组配置状态总览（替代旧的碎片状态徽章） */
.status-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.status-group {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.status-group-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 9px;
}
.status-group-head strong {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}
.status-group-state {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
}
.status-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
}
.status-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.status-dot.off { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.status-dot.mid { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.status-group-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.status-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}
.status-line span {
  flex: none;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.status-line strong {
  min-width: 0;
  color: var(--ink);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  margin-left: auto;
}
.status-line .dot-mini {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-faint);
}
.status-line .dot-mini.on { background: var(--ok); }
.status-line .dot-mini.off { background: var(--danger); }

/* 设置分区标签 */
.settings-tabs {
  display: flex;
  gap: 3px;
  padding: 4px;
  width: fit-content;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.settings-tab {
  border: none;
  background: transparent;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.settings-tab:hover { color: var(--ink); }
.settings-tab.active {
  background: var(--accent);
  color: #fff;
}
.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-panel[hidden] { display: none; }
.knowledge-layout,
.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.8fr);
  gap: 16px;
}

/* 知识库工作台 */
.kb-workbench {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) minmax(260px, 300px);
  gap: 14px;
  height: calc(100vh - var(--topbar-h) - 44px);
  min-height: 640px;
}
.kb-list-pane,
.kb-editor-pane,
.kb-side-pane {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.kb-list-pane,
.kb-side-pane {
  padding: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.kb-editor-pane {
  padding: 16px 18px;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.kb-type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.kb-tab {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.kb-tab:hover { background: #f1f5f9; }
.kb-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}
.kb-list-meta {
  margin-bottom: 8px;
  font-size: 11px;
}
.kb-item-list {
  flex: 1;
  min-height: 120px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 2px;
}
.kb-item {
  width: 100%;
  text-align: left;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.kb-item:hover {
  background: #f1f5f9;
  border-color: var(--line);
}
.kb-item.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.kb-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.kb-item-title {
  font-weight: 800;
  font-size: 13px;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.kb-item-snippet {
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.kb-item-meta {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  color: var(--ink-muted);
}
.kb-list-foot {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.kb-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.kb-editor-head h2 {
  margin: 0;
  font-size: 18px;
}
.kb-editor-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.kb-content-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.kb-content-field textarea {
  flex: 1;
  min-height: 280px;
  resize: vertical;
  line-height: 1.55;
}
.kb-side-pane .side-hint {
  margin: 0 0 10px;
  font-size: 12px;
}
.kb-test-results {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}
.kb-compare-table {
  overflow: auto;
  font-size: 12px;
}
.kb-compare-table table {
  width: 100%;
  border-collapse: collapse;
}
.kb-compare-table th,
.kb-compare-table td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  vertical-align: top;
  text-align: left;
}
.kb-compare-table th {
  background: var(--surface-soft);
  font-weight: 600;
}
.kb-compare-head {
  margin-bottom: 6px;
  font-size: 12px;
}
.agent-action-panel {
  margin: 14px 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.06), transparent);
}
.agent-action-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
}
.agent-action-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}
.agent-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.agent-action-row strong {
  display: block;
  font-size: 13px;
  margin: 4px 0 2px;
}
.agent-action-row p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-muted);
}
.deep-link-highlight {
  outline: 2px solid rgba(59, 130, 246, 0.55);
  outline-offset: 2px;
  background: rgba(59, 130, 246, 0.06) !important;
}
.kb-structured-panel {
  margin: 8px 0 12px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: #fafbfd;
}
.kb-structured-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}
.kb-structured-head .sub {
  margin: 4px 0 0;
  font-size: 12px;
}
.kb-structured-actions {
  flex-wrap: wrap;
  gap: 6px;
}
.kb-sync-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--ink-muted);
}
.task-link-row {
  gap: 8px;
}
.kb-structured-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 900px) {
  .kb-structured-grid { grid-template-columns: 1fr; }
}
.kb-hit {
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.kb-hit:hover {
  background: #f8fafc;
  border-color: var(--accent-line);
}
.kb-hit-score {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--ink-muted);
}
.kb-hit strong {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}
.kb-hit p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.45;
}
.kb-upload-panel {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.kb-upload-panel.hidden { display: none; }
.kb-upload-result,
.kb-upload-summary {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}
.hidden { display: none !important; }
.members-shell {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(320px, 0.9fr) minmax(280px, 0.72fr);
  gap: 16px;
  align-items: start;
}

.stat-card,
.metric-card {
  padding: 14px 16px;
  min-height: 96px;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.1;
  font-weight: 700;
  color: var(--ink);
}
.stat-label {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}
.stat-hint {
  margin-top: 3px;
  color: var(--ink-muted);
  font-size: 12px;
}

.bar-row { margin-bottom: 12px; }
.bar-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 13px;
  margin-bottom: 6px;
}
.bar-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f7;
}
.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--info));
  transition: width 0.3s ease;
}

/* 表单 */
.field { margin-bottom: 13px; }
.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 700;
}
/* 密钥字段的配置状态徽标（已配置 xx****yy / 未配置） */
.key-state {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  vertical-align: 1px;
}
.key-state.on {
  background: var(--ok-soft);
  color: var(--ok);
}
.key-state.off {
  background: rgba(220, 38, 38, 0.09);
  color: var(--danger);
}
.field input,
.field select,
.field textarea,
.toolbar-input,
.toolbar-select,
input:not([type="file"]):not([type="checkbox"]),
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.field textarea,
textarea {
  resize: vertical;
  min-height: 88px;
}
.field input::placeholder,
.field textarea::placeholder,
input::placeholder,
textarea::placeholder { color: var(--ink-faint); }
.field input:focus,
.field select:focus,
.field textarea:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}
.field .hint,
.hint {
  margin-top: 5px;
  color: var(--ink-muted);
  font-size: 12px;
}
input[type="file"] {
  width: 100%;
  min-height: 38px;
  padding: 7px 8px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink-soft);
}

.row,
.toolbar-row,
.filter-grid {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.toolbar-row {
  margin-bottom: 14px;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr)) auto auto;
  align-items: end;
}
.toolbar-row > input,
.toolbar-row > select,
.filter-grid > input,
.filter-grid > select {
  flex: 1;
  min-width: 140px;
}
.toolbar-row #m-ie-hint {
  flex: 1 1 140px;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--accent-strong);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}
.btn:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
.btn:active { transform: translateY(1px); }
.btn-ghost {
  background: #fff;
  color: var(--ink-soft);
  border-color: var(--line-strong);
}
.btn-ghost:hover {
  background: var(--surface-soft);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.btn-small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}
.btn-mini {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
  margin-top: 8px;
}

/* 通用信息 */
.kv {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.kv:last-child { border-bottom: none; }
.kv span:first-child {
  color: var(--ink-muted);
  flex-shrink: 0;
}
.kv span:last-child {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}
.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}
.text-muted { color: var(--ink-muted) !important; }
.text-warn { color: var(--warn) !important; }
.text-danger { color: var(--danger) !important; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.strong {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #b8e3cb;
}
.badge.medium {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: #f3d591;
}
.badge.weak,
.badge.none {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fac5bf;
}

pre.json {
  margin: 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #0f172a;
  color: #dbeafe;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}

/* 旧调试消息样式保留给复用片段 */
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  min-height: 60px;
}
.msg {
  max-width: 78%;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}
.msg.agent {
  align-self: flex-start;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}
.msg .meta {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  opacity: 0.7;
}

/* 企微会话工作台 */
.wecom-workbench {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 1fr) minmax(280px, 340px);
  gap: 14px;
  height: calc(100vh - var(--topbar-h) - 44px);
  min-height: 640px;
}
.inbox-pane,
.thread-pane,
.customer-pane {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.inbox-pane,
.customer-pane {
  padding: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.thread-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}
.pane-head .sub,
.thread-head .sub {
  margin: 0;
  color: var(--ink-muted);
  font-size: 12px;
}
.field.compact { margin-bottom: 9px; }
.field.compact input,
.field.compact textarea {
  min-height: 34px;
  padding: 7px 9px;
  font-size: 13px;
}
.field.compact textarea { min-height: 74px; }
.inbox-tools {
  margin-bottom: 10px;
}
.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 180px;
  padding-right: 2px;
  overflow: auto;
}
.conversation-item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.conv-body {
  flex: 1;
  min-width: 0;
}

/* 微信头像（真实头像 + 首字降级） */
.avatar {
  position: relative;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-tint);
}
.avatar img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar i {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-style: normal;
  font-weight: 700;
  font-size: 15px;
}
.avatar.avatar-lg {
  width: 48px;
  height: 48px;
}
.avatar.avatar-lg i { font-size: 19px; }
.conversation-item:hover {
  background: #f1f5f9;
  border-color: var(--line);
}
.conversation-item.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.conv-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}
.conv-name {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-msg,
.conv-meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-msg {
  color: var(--ink-soft);
  font-size: 12.5px;
}
.conv-meta {
  margin-top: 4px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}
.side-title {
  margin-bottom: 8px;
  color: var(--ink);
  font-weight: 800;
}
.kb-del-btn {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}
.kb-del-btn:hover {
  background: #fecaca;
}
.thread-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.thread-status {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.thread-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  overflow: auto;
  background: #fbfcfe;
}
.thread-row { display: flex; }
.thread-row.customer { justify-content: flex-start; }
.thread-row.agent { justify-content: flex-end; }
.thread-row.employee { justify-content: flex-end; }
.thread-bubble {
  max-width: min(76%, 680px);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}
.thread-row.customer .thread-bubble {
  border-left: 3px solid var(--info);
}
.thread-row.agent .thread-bubble {
  background: var(--accent);
  border-color: var(--accent-strong);
  color: #fff;
}
.thread-row.employee .thread-bubble {
  background: #2f6fed;
  border-color: #2459c7;
  color: #fff;
}
.thread-meta {
  margin-bottom: 5px;
  color: var(--ink-muted);
  font-size: 11px;
}
.thread-row.agent .thread-meta,
.thread-row.employee .thread-meta { color: rgba(255,255,255,0.78); }
.thread-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.reply-composer {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.reply-composer textarea {
  width: 100%;
  min-height: 86px;
  margin-bottom: 10px;
}
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.checkline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: auto;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
}
.checkline input { width: auto; min-height: auto; }
.tag-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 10px 8px 0;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 700;
}
.tag-check input {
  width: auto;
  min-height: auto;
}
.customer-pane { overflow: auto; }
.side-section {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.side-profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.side-profile-name {
  min-width: 0;
}
.side-profile-name strong {
  display: block;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-profile-name span {
  display: block;
  margin-top: 2px;
  color: var(--ink-muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-section:last-child {
  margin-bottom: 0;
  border-bottom: none;
}
.agent-draft {
  margin-bottom: 10px;
  padding: 11px;
  border: 1px solid #f3d591;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.side-hint {
  margin: 8px 0 0;
  color: var(--ink-muted);
  font-size: 11px;
  line-height: 1.4;
}
.side-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.goal-card {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  margin-bottom: 8px;
}
.goal-card:last-child { margin-bottom: 0; }
.goal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}
.goal-dots {
  display: flex;
  gap: 5px;
  margin-bottom: 4px;
}
.goal-dot {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--line-strong);
}
.goal-dot.done { background: var(--accent, #1f8a5f); }
.goal-stage-label {
  font-size: 11.5px;
  color: var(--ink-muted);
  margin-bottom: 8px;
}
.goal-actions {
  display: flex;
  gap: 6px;
}
.btn-danger-ghost {
  color: var(--danger);
  border-color: var(--danger-soft);
}
.btn-danger-ghost:hover {
  background: var(--danger-soft);
}
summary.side-title {
  cursor: pointer;
  user-select: none;
}
.side-summary-hint {
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 500;
}
.agent-trace-section[open] summary.side-title {
  margin-bottom: 8px;
}
.agent-flag {
  margin: 8px 0;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-soft);
}
.agent-flag.medium {
  border-color: #f3d591;
  background: var(--warn-soft);
}
.agent-trace-meta {
  margin-bottom: 8px;
  font-size: 11px;
  color: var(--ink-muted);
}
.agent-trace-notes {
  margin-bottom: 8px;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-soft);
}
.agent-kb-refs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 11px;
}
.kb-ref-chip {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  font-size: 10px;
}
.agent-trace-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.agent-trace-step {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}
.agent-trace-idx {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
}
.agent-trace-step strong {
  display: block;
  font-size: 12px;
  margin-bottom: 2px;
}
.agent-trace-step p {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--ink-muted);
}
.memory-line {
  margin-bottom: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink-soft);
}
.compact-empty { padding: 16px 8px; }

/* 结果与列表 */
.result-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.result-item {
  position: relative;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color 0.16s ease, background 0.16s ease;
}
.result-item.selectable { cursor: pointer; }
.result-item:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}
.result-item.selected {
  border-color: var(--accent-line) !important;
  background: #fff !important;
  box-shadow: inset 4px 0 0 var(--accent);
}
.result-item .title {
  margin-bottom: 4px;
  color: var(--ink);
  font-weight: 800;
}
.result-item .score {
  float: right;
  margin-left: 10px;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}
.feedback-reason {
  margin: 6px 0;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  border: 1px solid #f3d591;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.feedback-diff {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.feedback-col-label {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
}
.feedback-text {
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.panel-warn {
  background: var(--warn-soft) !important;
  border-color: #f3d591 !important;
}
.panel-suggest {
  background: var(--info-soft) !important;
  border-color: #b9c8ef !important;
  margin-bottom: 14px;
}
.panel-liquor {
  margin-top: 12px;
  background: #f4ecff !important;
  border-color: #d8c2f3 !important;
}

.empty {
  padding: 26px 16px;
  color: var(--ink-muted);
  text-align: center;
  font-size: 13px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 100;
  transform: translateX(-50%) translateY(16px);
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-panel);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.ok { background: var(--ok); border-color: var(--ok); }
.toast.err { background: var(--danger); border-color: var(--danger); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #c7d0dd;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: #aeb9c9; background-clip: padding-box; }

@media (max-width: 1240px) {
  .dash-grid,
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .members-shell,
  .knowledge-layout,
  .review-layout { grid-template-columns: 1fr; }
  .kb-workbench {
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
    height: auto;
  }
  .kb-side-pane { grid-column: 1 / -1; max-height: none; }
  .wecom-workbench {
    grid-template-columns: minmax(240px, 310px) minmax(0, 1fr);
    height: auto;
  }
  .customer-pane { grid-column: 1 / -1; max-height: none; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 76px; }
  .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .sidebar { padding: 14px 8px; }
  .brand { justify-content: center; padding: 2px 0 14px; }
  .brand-text,
  .sidebar-foot { display: none; }
  .nav-item {
    justify-content: center;
    padding: 9px;
    font-size: 0;
  }
  .nav-item .ico { width: 20px; height: 20px; }
  .content { padding: 18px; }
  .topbar { padding: 0 18px; }
  .grid-2,
  .module-grid,
  .filter-grid { grid-template-columns: 1fr; }
  .agent-console {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
  .agent-chat-panel {
    height: 72vh;
    min-height: 460px;
  }
  .agent-side-panel {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .agent-side-block {
    flex: 1;
    min-width: 260px;
  }
  .agent-context-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .settings-row {
    grid-template-columns: 1fr;
  }
  .settings-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .status-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .settings-actions {
    flex-direction: row;
    min-width: 0;
  }
  .settings-actions .btn {
    width: auto;
  }
  .settings-tabs {
    width: 100%;
    overflow-x: auto;
  }
  .wecom-workbench { grid-template-columns: 1fr; }
  .thread-log { min-height: 420px; }
  .thread-bubble { max-width: 92%; }
}

@media (max-width: 620px) {
  :root { --sidebar-w: 0px; }
  .app { display: block; }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 10px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .brand { justify-content: flex-start; padding: 2px 4px 10px; }
  .brand-text { display: flex; }
  .nav {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .nav-item {
    flex: 0 0 auto;
    font-size: 13px;
    justify-content: flex-start;
    min-width: max-content;
  }
  .topbar {
    position: static;
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }
  .status-pills { justify-content: flex-start; }
  .content { padding: 14px; }
  .dash-grid,
  .metric-grid { grid-template-columns: 1fr; }
  .agent-chat-head {
    flex-direction: column;
    align-items: stretch;
  }
  .agent-chat-head-actions { justify-content: flex-start; }
  .agent-side-panel { flex-direction: column; }
  .agent-action-item {
    grid-template-columns: 1fr;
  }
  .agent-context-grid {
    grid-template-columns: 1fr;
  }
  .agent-input-row {
    flex-wrap: wrap;
  }
  .agent-input-row .btn {
    flex: 1;
    min-width: 120px;
  }
  #agent-command { flex-basis: 100%; }
  .agent-action-item .btn {
    width: 100%;
  }
  .settings-row,
  .settings-status-row {
    padding: 14px;
  }
  .settings-form-grid,
  .settings-status-grid {
    grid-template-columns: 1fr;
  }
  .settings-actions {
    flex-direction: column;
  }
  .settings-actions .btn {
    width: 100%;
  }
  .composer-actions .btn,
  .composer-actions .btn-ghost { flex: 1; }
  .checkline { width: 100%; }
}
