/* ---------------------------------------------------------------------------
   组件样式。颜色一律引用 brand.css 的知问设计令牌（--zw-*），
   组件名保持稳定，换肤只需改 brand.css。
   ------------------------------------------------------------------------- */

:root {
  /* 主色（湖青蓝） */
  --primary: var(--zw-primary);
  --primary-dark: var(--zw-primary-active);
  --primary-hover: var(--zw-primary-hover);
  --primary-soft: var(--zw-primary-light);
  --primary-border: var(--zw-primary-border);

  /* 强调色（琥珀） */
  --accent: var(--zw-accent);
  --accent-soft: var(--zw-accent-light);
  --accent-border: var(--zw-accent-border);

  /* AI 色（青绿） */
  --ai: var(--zw-ai);
  --ai-soft: var(--zw-ai-light);
  --ai-border: var(--zw-ai-border);

  /* 语义色 */
  --success: var(--zw-success);
  --success-soft: var(--zw-success-bg);
  --success-border: var(--zw-ai-border);
  --danger: var(--zw-error);
  --danger-soft: var(--zw-error-bg);
  --danger-border: #E2B6A6;
  --warning: var(--zw-warning);
  --warning-soft: var(--zw-warning-bg);
  --warning-border: var(--zw-accent-border);

  /* 背景 */
  --bg: var(--zw-bg-page);
  --bg-gradient: var(--zw-bg-page-gradient);
  --surface: var(--zw-bg-card);
  --surface-alt: var(--zw-bg-secondary);
  --surface-hover: var(--zw-bg-hover);
  --border: var(--zw-border);
  --border-strong: var(--zw-border-strong);
  --border-subtle: var(--zw-border-subtle);

  /* 文字 */
  --text: var(--zw-text-primary);
  --text-secondary: var(--zw-text-secondary);
  --text-muted: var(--zw-text-tertiary);

  /* 圆角 / 间距 / 阴影 / 字体（沿用知问令牌） */
  --radius-sm: var(--zw-radius-sm);
  --radius: var(--zw-radius-md);
  --radius-lg: var(--zw-radius-lg);
  --radius-xl: var(--zw-radius-xl);

  --space-1: var(--zw-space-1);
  --space-2: var(--zw-space-2);
  --space-3: var(--zw-space-3);
  --space-4: var(--zw-space-4);
  --space-5: var(--zw-space-5);
  --space-6: var(--zw-space-6);
  --space-8: var(--zw-space-8);

  --shadow-sm: var(--zw-shadow-sm);
  --shadow: var(--zw-shadow-md);
  --shadow-lg: var(--zw-shadow-lg);

  --gradient-primary: var(--zw-gradient-primary);

  /* 图标色环：在知问主色体系上扩展的低饱和关联色，
     用于菜单图标底色与统计卡配色，保证饱和/明度一致。 */
  --ic-blue: #1B7FC4;
  --ic-teal: #0FA68B;
  --ic-amber: #DE9B2C;
  --ic-violet: #7159C9;
  --ic-rose: #CF5378;
  --ic-cyan: #1899B5;
  --ic-lime: #6E9B2E;
  --ic-orange: #DE7033;
  --ic-indigo: #4F6BD8;
  --ic-plum: #A05BB5;

  --font: var(--zw-font-sans);
  --mono: var(--zw-font-mono);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg) var(--bg-gradient) fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------------------------------------------------------------- layout */

.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.brand {
  padding: var(--space-5) var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(165deg, #EEF6FC 0%, #F7FBFE 42%, rgba(255,255,255,0) 100%);
}
.brand-mark {
  display: flex; align-items: center; gap: var(--space-2);
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
}
.brand-logo {
  width: 28px; height: 28px; flex: none; display: block;
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; color: var(--text); }
.brand-sub {
  margin-top: var(--space-2);
  display: flex; align-items: center; gap: var(--space-2);
  font-size: 11px; color: var(--text-muted); letter-spacing: 0.02em;
}

.nav { padding: var(--space-3) var(--space-2); overflow-y: auto; flex: 1; }
.nav-group { margin-bottom: var(--space-4); }
.nav-label {
  padding: 0 var(--space-2) var(--space-2);
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted);
}
.nav button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 5px var(--space-2); margin-bottom: 2px;
  border: none; background: none; border-radius: var(--radius);
  cursor: pointer; color: var(--text-secondary); text-align: left;
  font-size: 13px; position: relative;
  transition: background 0.14s, color 0.14s;
}
.nav button:hover { background: var(--surface-hover); color: var(--text); }
.nav button.active { background: var(--ic-bg); color: var(--ic); font-weight: 600; }
.nav button.active::before {
  content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--ic) 0%, var(--ic-b) 100%);
}
.nav .icon {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px; background: var(--ic-bg); color: var(--ic);
  transition: background 0.16s, color 0.16s, box-shadow 0.16s;
}
.nav .icon svg {
  width: 15px; height: 15px; display: block;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav button.active .icon {
  background: linear-gradient(140deg, var(--ic) 0%, var(--ic-b) 100%);
  color: #fff;
  box-shadow: 0 4px 10px -3px var(--ic-shadow), inset 0 1px 0 rgba(255,255,255,0.32);
}
.nav button.active .icon svg { stroke-width: 2; }

/* 每个菜单项的图标配色：常态为浅底彩标，选中态为同色渐变实心标 */
.nav button[data-page="dashboard"] { --ic: var(--ic-blue);   --ic-b: #12A08F; --ic-bg: #E8F2FA; --ic-shadow: rgba(27,127,196,0.32); }
.nav button[data-page="leads"]     { --ic: var(--ic-teal);   --ic-b: #12B49B; --ic-bg: #E3F5F0; --ic-shadow: rgba(15,166,139,0.32); }
.nav button[data-page="calls"]     { --ic: var(--ic-amber);  --ic-b: #E8B454; --ic-bg: #FAEFD9; --ic-shadow: rgba(222,155,44,0.32); }
.nav button[data-page="campaigns"] { --ic: var(--ic-violet); --ic-b: #8C77DA; --ic-bg: #E9E4F9; --ic-shadow: rgba(113,89,201,0.32); }
.nav button[data-page="agent"]     { --ic: var(--ic-rose);   --ic-b: #DE7697; --ic-bg: #FBE8EE; --ic-shadow: rgba(207,83,120,0.32); }
.nav button[data-page="knowledge"] { --ic: var(--ic-cyan);   --ic-b: #3BB2CB; --ic-bg: #E3F3F7; --ic-shadow: rgba(24,153,181,0.32); }
.nav button[data-page="lab"]       { --ic: var(--ic-lime);   --ic-b: #8CB84A; --ic-bg: #F0F5E3; --ic-shadow: rgba(110,155,46,0.32); }
.nav button[data-page="runtime"]   { --ic: var(--ic-orange); --ic-b: #E98F59; --ic-bg: #FBEEE5; --ic-shadow: rgba(222,112,51,0.32); }
.nav button[data-page="settings"]  { --ic: var(--ic-indigo); --ic-b: #7489E3; --ic-bg: #E4E9FB; --ic-shadow: rgba(79,107,216,0.32); }
.nav button[data-page="rules"]     { --ic: var(--ic-plum);   --ic-b: #B478C6; --ic-bg: #F3E9F7; --ic-shadow: rgba(160,91,181,0.32); }

.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-muted);
}
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; }
.status-dot.on { background: var(--success); }
.status-dot.off { background: var(--text-muted); }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 52px; flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-6); position: relative;
}
.topbar::after {
  content: ""; position: absolute; left: 0; bottom: -1px; width: 96px; height: 2px;
  background: var(--zw-gradient-primary); border-radius: 0 2px 2px 0;
}
.topbar h1 { font-size: 15px; font-weight: 600; margin: 0; }
.topbar .crumb { font-size: 12px; color: var(--text-muted); }

.content { flex: 1; overflow-y: auto; padding: var(--space-6); }

.page { display: none; }
.page.active { display: block; animation: fade 0.15s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.page-head { margin-bottom: var(--space-5); }
.page-head h2 { margin: 0 0 var(--space-1); font-size: 18px; font-weight: 600; }
.page-head p { margin: 0; color: var(--text-secondary); font-size: 13px; }
.page-head .actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); flex-wrap: wrap; }

/* ----------------------------------------------------------------- cards */

.grid { display: grid; gap: var(--space-4); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-head {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #FBFCFE 0%, #FFFFFF 100%);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
}
.card-head h3 {
  margin: 0; font-size: 14px; font-weight: 600;
  position: relative; padding-left: 11px;
}
.card-head h3::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 14px; border-radius: 2px;
  background: var(--zw-gradient-primary);
}
.card-head small { color: var(--text-muted); font-size: 12px; }
.card-body { padding: var(--space-5); }
.card-body.tight { padding: var(--space-3) var(--space-4); }

/* 统计卡：彩色渐变洗底 + 渐变图标块 + 彩色数值 + 进度条 */
.card.stat {
  position: relative;
  padding: var(--space-4) var(--space-5);
  background: linear-gradient(158deg, var(--ic-bg) 0%, #FFFFFF 56%, #FFFFFF 100%);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.card.stat::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, var(--ic) 0%, var(--ic-b) 100%);
}
.card.stat::after {
  content: ""; position: absolute; right: -36px; top: -46px;
  width: 130px; height: 130px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, var(--ic) 0%, rgba(255,255,255,0) 70%);
  opacity: 0.12;
}
.card.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-head { display: flex; align-items: center; gap: 9px; }
.stat-icon {
  width: 28px; height: 28px; flex: none; border-radius: 9px;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--ic) 0%, var(--ic-b) 100%);
  box-shadow: 0 4px 10px -3px var(--ic-shadow), inset 0 1px 0 rgba(255,255,255,0.32);
}
.stat-icon svg {
  width: 15px; height: 15px; display: block;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
.stat-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.stat-value {
  font-size: 30px; font-weight: 700; line-height: 1.1; margin-top: 10px;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--ic);
}
.stat-hint { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
.stat-meter { margin-top: 12px; height: 4px; border-radius: 999px; background: rgba(20,30,50,0.07); overflow: hidden; }
.stat-meter i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--ic) 0%, var(--ic-b) 100%); transition: width 0.5s ease; }

/* 四张统计卡的配色（与左侧菜单同色系，保持全局一致） */
#statCards > .card.stat:nth-child(1) { --ic: var(--ic-blue);   --ic-b: #12A08F; --ic-bg: #E2EEF9; --ic-shadow: rgba(27,127,196,0.32); }
#statCards > .card.stat:nth-child(2) { --ic: var(--ic-teal);   --ic-b: #12B49B; --ic-bg: #DDF2EC; --ic-shadow: rgba(15,166,139,0.32); }
#statCards > .card.stat:nth-child(3) { --ic: var(--ic-amber);  --ic-b: #E8B454; --ic-bg: #FAEFD9; --ic-shadow: rgba(222,155,44,0.32); }
#statCards > .card.stat:nth-child(4) { --ic: var(--ic-violet); --ic-b: #8C77DA; --ic-bg: #E9E4F9; --ic-shadow: rgba(113,89,201,0.32); }

/* --------------------------------------------------------------- controls */

.btn {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 6px 13px; border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, #FFFFFF 0%, #FAFBFD 100%);
  color: var(--text); cursor: pointer; font-size: 13px;
  box-shadow: 0 1px 2px rgba(20,30,50,0.06), inset 0 1px 0 #FFFFFF;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s, color 0.12s, background 0.12s;
  white-space: nowrap; text-decoration: none;
}
.btn:hover {
  border-color: var(--primary-border); color: var(--primary);
  background: linear-gradient(180deg, #FFFFFF 0%, #EFF6FC 100%);
  box-shadow: 0 3px 8px -2px rgba(27,127,196,0.20), inset 0 1px 0 #FFFFFF;
}
.btn:active { transform: translateY(1px); box-shadow: inset 0 2px 4px rgba(20,30,50,0.13); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

/* 主按钮：知问品牌渐变（湖青蓝 → 青绿），附带同色泛光 */
.btn.primary {
  background: var(--zw-gradient-primary); border-color: transparent; color: #fff;
  box-shadow: 0 3px 10px -3px rgba(27,127,196,0.55), inset 0 1px 0 rgba(255,255,255,0.28);
}
.btn.primary:hover {
  background: linear-gradient(135deg, #15629B 0%, #0B8E7A 100%); color: #fff;
  box-shadow: 0 7px 18px -5px rgba(27,127,196,0.55), inset 0 1px 0 rgba(255,255,255,0.28);
}
.btn.accent {
  background: linear-gradient(135deg, #F2BC63 0%, #E8A13A 100%);
  border-color: transparent; color: #6B4708;
  box-shadow: 0 3px 10px -3px rgba(232,161,58,0.5), inset 0 1px 0 rgba(255,255,255,0.45);
}
.btn.accent:hover { background: linear-gradient(135deg, #E8A13A 0%, #D98A22 100%); color: #5A3B06; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-secondary); }
.btn.ghost:hover { background: var(--surface-hover); color: var(--text); box-shadow: none; }
.btn.danger { color: var(--danger); border-color: var(--danger-border); }
.btn.danger:hover {
  background: linear-gradient(135deg, #B5472C 0%, #C95B3D 100%);
  border-color: transparent; color: #fff;
  box-shadow: 0 4px 12px -4px rgba(181,71,44,0.5);
}
.btn.sm { padding: 3px 9px; font-size: 12px; }
/* 列表行内删除：默认低调，悬停才予警示色，避免成排红色干扰阅读 */
.btn.danger.sm {
  border-color: transparent; background: transparent; box-shadow: none;
  color: var(--text-muted); padding: 3px 8px;
}
.btn.danger.sm:hover {
  background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger);
  box-shadow: none; transform: none;
}

.field { margin-bottom: var(--space-3); }
.field label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: var(--space-1); }
.field input, .field select, .field textarea {
  width: 100%; padding: 7px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); outline: none; transition: border 0.12s, box-shadow 0.12s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft);
}
.field textarea { resize: vertical; min-height: 72px; font-family: inherit; }
.field .help { font-size: 11px; color: var(--text-muted); margin-top: var(--space-1); }
.field .help.warn-text { color: var(--warning); font-weight: 500; }
.field .help.ok-text { color: var(--success); }
.warn-text { color: var(--warning); }
.ok-text { color: var(--success); }
.tag {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; line-height: 18px; color: var(--primary);
  background: var(--primary-soft); border: 1px solid var(--primary-border);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 500;
  background: var(--surface-alt); color: var(--text-secondary); border: 1px solid var(--border);
}
.badge.green { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge.blue { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-border); }
.badge.orange { background: var(--accent-soft); color: var(--warning); border-color: var(--accent-border); }
.badge.red { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.badge.grey { background: var(--surface-alt); color: var(--text-muted); }

/* ----------------------------------------------------------------- table */

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: var(--space-3) var(--space-4);
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  background: linear-gradient(180deg, #F8FAFC 0%, #F3F6FA 100%);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
}
.table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--primary-soft); cursor: default; }
.table tbody tr.clickable:hover { cursor: pointer; }
.table .muted { color: var(--text-muted); font-size: 12px; }
.table-wrap { overflow: auto; max-height: calc(100vh - 320px); border-radius: var(--radius); border: 1px solid var(--border); }

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

/* ------------------------------------------------------------------ list */

.list-item {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-alt); }
.list-item .title { font-weight: 500; font-size: 13px; }
.list-item .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.list-item .body { flex: 1; min-width: 0; }

/* --------------------------------------------------------------- process */

.pipe { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.pipe-node {
  padding: var(--space-2) var(--space-3); border-radius: var(--radius);
  background: var(--surface-alt); border: 1px solid var(--border);
  font-size: 12px; font-family: var(--mono);
}
.pipe-arrow { color: var(--text-muted); font-size: 12px; }

.timeline { position: relative; padding-left: var(--space-5); }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 1px; background: var(--border);
}
.timeline-item { position: relative; padding-bottom: var(--space-4); }
.timeline-item::before {
  content: ""; position: absolute; left: -18px; top: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--primary-border);
}
.timeline-item.green::before { border-color: var(--success); }
.timeline-item.orange::before { border-color: var(--accent); }
.timeline-item.red::before { border-color: var(--danger); }
.timeline-item .t-head { display: flex; align-items: center; gap: var(--space-2); }
.timeline-item .t-type { font-size: 12px; font-family: var(--mono); font-weight: 500; }
.timeline-item .t-time { font-size: 11px; color: var(--text-muted); }
.timeline-item .t-body {
  margin-top: var(--space-1); font-size: 12px; color: var(--text-secondary);
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3);
  font-family: var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow: auto;
}

/* ------------------------------------------------------------------ chat */

.chat { display: flex; flex-direction: column; gap: var(--space-3); max-height: 420px; overflow-y: auto; padding: var(--space-4); }
.msg { display: flex; gap: var(--space-2); }
.msg .avatar {
  width: 26px; height: 26px; border-radius: var(--radius); flex-shrink: 0;
  display: grid; place-items: center; font-size: 11px; font-weight: 600;
}
.msg.agent .avatar { background: linear-gradient(140deg, #1B7FC4 0%, #12A08F 100%); color: #fff; }
.msg.customer .avatar { background: linear-gradient(140deg, #E8A13A 0%, #D98A22 100%); color: #fff; }
.msg .bubble {
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-lg);
  font-size: 13px; max-width: 82%; border: 1px solid var(--border); background: var(--surface);
}
.msg.agent .bubble { border-color: var(--primary-border); background: linear-gradient(160deg, #F2F8FD 0%, #EAF3FB 100%); }
.msg .meta { font-size: 11px; color: var(--text-muted); margin-top: var(--space-1); }

.composer { display: flex; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); }
.composer input { flex: 1; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); }

/* ---------------------------------------------------------------- modals */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(26, 29, 33, 0.35);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: var(--space-6);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-xl);
  width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.modal.wide { max-width: 860px; }
.modal-head {
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #F7FAFD 0%, #FFFFFF 100%);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: var(--space-5); }
.modal-foot {
  padding: var(--space-4) var(--space-5); border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: var(--space-2);
}

/* ----------------------------------------------------------------- toast */

.toast-wrap { position: fixed; top: var(--space-5); right: var(--space-5); z-index: 200; display: flex; flex-direction: column; gap: var(--space-2); }
.toast {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: 13px; max-width: 380px;
  animation: slide 0.18s ease;
}
.toast.ok { border-left: 3px solid var(--success); }
.toast.err { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }
@keyframes slide { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------- utilities */

.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: var(--space-2); }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.ml-2 { margin-left: var(--space-2); }
/* 设置页里用来分隔「线路参数」与「AI 坐席」两块，别让它们挤成一片 */
.divider { height: 1px; background: var(--zw-border-subtle); margin: var(--space-4) 0; }
.label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2); }
.label-row > label { font-size: 12px; font-weight: 600; color: var(--zw-text-primary); }
.mb-3 { margin-bottom: var(--space-3); }
.stack > * + * { margin-top: var(--space-3); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-2) 0; font-size: 13px; }
.check .mark {
  width: 18px; height: 18px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  margin-top: 2px; line-height: 1; color: #fff;
}
.check.ok .mark { background: linear-gradient(140deg, #15B698 0%, #0FA68B 100%); box-shadow: 0 3px 7px -2px rgba(15,166,139,0.55); }
.check.no .mark { background: linear-gradient(140deg, #D0623F 0%, #B5472C 100%); box-shadow: 0 3px 7px -2px rgba(181,71,44,0.5); }
.check .hint { font-size: 12px; color: var(--text-muted); }

/* ---------------------------------------------------------------- 搜索 / 分页 / 规则 */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  padding: var(--space-3); margin-bottom: var(--space-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.toolbar input[type="search"], .toolbar input[type="text"], .toolbar select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); font-size: 13px; min-width: 130px;
}
.toolbar input[type="search"] { min-width: 220px; }
.toolbar .grow { flex: 1; }
.toolbar .count { font-size: 12px; color: var(--text-muted); margin-left: auto; }

.pager {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-3); border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted);
}
.pager .spacer { flex: 1; }
.pager button:disabled { opacity: 0.45; cursor: not-allowed; }

/* 规则配置：每个开关一行，右侧是"关掉它意味着什么" */
.rule-row { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.rule-row:last-child { border-bottom: 0; }
.rule-row .rule-body { flex: 1; }
.rule-row .rule-title { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.rule-row .rule-help { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.rule-row .rule-risk { font-size: 12px; color: var(--warning); margin-top: 2px; }
.switch { position: relative; width: 42px; height: 24px; flex: none; margin-top: 2px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: .15s; cursor: pointer; }
.switch .slider:before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + .slider { background: var(--success, #15B698); }
.switch input:checked + .slider:before { transform: translateX(18px); }

/* 规则横幅：宽松模式必须显眼 */
.banner { padding: var(--space-3); border-radius: var(--radius); margin-bottom: var(--space-3); font-size: 13px; }
.banner.warn { background: rgba(208,98,63,0.12); border: 1px solid rgba(208,98,63,0.45); color: var(--warning); }
.banner.ok { background: rgba(21,182,152,0.10); border: 1px solid rgba(21,182,152,0.35); color: var(--success); }

/* 手动选线索 */
.picker { max-height: 340px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
.picker table { width: 100%; }
.picker tr.picked { background: rgba(21,182,152,0.10); }
.picked-bar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; padding: var(--space-2) 0; }

/* 可点的小徽标（如线索的授权状态）：点一下就能改，不必先找“编辑”按钮。 */
.linky { cursor: pointer; }
.linky:hover { text-decoration: underline; text-underline-offset: 2px; }
