:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #ea580c;
  --amber: #d97706;
  --purple: #7c3aed;
  --slate: #475569;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 14px; }
.logo { font-size: 26px; }
.brand-name { font-size: 16px; font-weight: 700; }
.brand-sub { font-size: 11px; color: #94a3b8; letter-spacing: .5px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #cbd5e1;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }

.badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  border-radius: 10px;
  padding: 1px 7px;
  font-weight: 700;
}
.badge.hidden { display: none; }

.sidebar-foot { font-size: 11px; color: #64748b; padding: 10px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; padding: 26px 30px 40px; min-width: 0; }

.tab { display: none; animation: fadeIn .25s ease; }
.tab.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 700; }
.sub { color: var(--muted); margin-top: 4px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card h3 { font-size: 15px; margin-bottom: 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card .value { font-size: 26px; font-weight: 800; margin-top: 6px; }
.stat-card .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.health-group { border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; background: var(--card); }
.health-group.health-danger { border-left-color: var(--red); }
.health-group.health-warn { border-left-color: var(--orange); }
.health-group.health-info { border-left-color: var(--primary); }
.health-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.health-head .health-title { font-weight: 700; font-size: 15px; }
.health-head .health-count { font-size: 13px; color: var(--red); font-weight: 700; }
.health-group table { margin-top: 4px; }
.alert-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.alert-head h3 { margin: 0; }
.inline-check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-bottom: 10px; }
.stat-click { cursor: pointer; transition: box-shadow .15s, transform .15s; }
.stat-click:hover { box-shadow: 0 6px 20px rgba(37,99,235,.16); transform: translateY(-2px); }
.aging-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.aging-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--card); }
.aging-card .aging-label { font-size: 12px; color: var(--muted); }
.aging-card .aging-count { font-size: 20px; font-weight: 800; margin-top: 4px; color: var(--text); }
.aging-card .aging-amount { font-size: 12px; color: var(--slate); margin-top: 2px; }
.aging-card.aging-warn { border-color: var(--orange); background: rgba(217,119,6,.06); }
.aging-card.aging-bad { border-color: var(--red); background: rgba(220,38,38,.06); }
.aging-card.aging-bad .aging-count { color: var(--red); }
.stat-blue { color: var(--primary); }
.stat-green { color: var(--green); }
.stat-orange { color: var(--orange); }
.stat-red { color: var(--red); }
.stat-purple { color: var(--purple); }

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }

.chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 90px; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .bar-label { color: var(--slate); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: #eef2f7; border-radius: 8px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 8px; min-width: 2px; transition: width .5s ease; }
.bar-value { text-align: right; color: var(--slate); white-space: nowrap; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: #f8fafc; }
tbody tr:hover { background: #f8fafc; }
.empty { text-align: center; color: var(--muted); padding: 26px 0; }

.status { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.st-草稿 { background: #f1f5f9; color: var(--slate); }
.st-审批中 { background: #dbeafe; color: var(--primary-dark); }
.st-已签署 { background: #ede9fe; color: var(--purple); }
.st-执行中 { background: #dcfce7; color: var(--green); }
.st-已到期 { background: #fee2e2; color: var(--red); }
.st-已终止 { background: #e2e8f0; color: var(--slate); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--red); }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn-right { margin-left: auto; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border .15s, box-shadow .15s;
  width: 100%;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.select { width: auto; min-width: 130px; }
.toolbar .input:first-child { flex: 1; min-width: 220px; }
.textarea { resize: vertical; font-family: inherit; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; color: var(--muted); font-size: 13px; }

.chat-card { display: flex; flex-direction: column; height: calc(100vh - 180px); min-height: 480px; }
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 4px; }
.msg { max-width: 82%; }
.msg-user { align-self: flex-end; }
.msg-agent { align-self: flex-start; }
.msg-bubble { padding: 12px 16px; border-radius: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.msg-user .msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg-agent .msg-bubble { background: #f8fafc; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg .mini-table { margin-top: 10px; overflow-x: auto; }
.msg .mini-table table { font-size: 12px; }
.msg-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.chat-suggestions { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 0 4px; }
.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.chat-input-row { display: flex; gap: 10px; margin-top: 10px; }
.btn-mic {
  border: 1px solid var(--border);
  background: #fff;
  font-size: 15px;
  line-height: 1;
  padding: 0 13px;
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
  flex: none;
}
.btn-mic:hover { border-color: var(--primary); background: #eff6ff; }
.btn-mic.listening {
  background: var(--red);
  border-color: var(--red);
  animation: mic-pulse 1s ease-in-out infinite;
}
.btn-mic:disabled { opacity: .5; cursor: not-allowed; }
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .45); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}
.voice-hint { font-size: 12px; color: var(--red); align-self: center; white-space: nowrap; }
.voice-hint.hidden { display: none; }
.mem-meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.sch-result { font-size: 12px; color: var(--muted); margin-top: 8px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; word-break: break-all; }
.notif-item.unread { border-left: 3px solid var(--primary); background: #eff6ff; }
/* 登录页 */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: linear-gradient(135deg, #1e3a8a, #312e81 55%, #4c1d95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-screen.hidden { display: none; }
.login-card {
  width: 360px;
  max-width: 100%;
  background: #fff;
  border-radius: 18px;
  padding: 34px 32px 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
  text-align: center;
}
.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card h1 { font-size: 20px; color: var(--slate); margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card .input { margin-bottom: 12px; text-align: left; }
.login-btn { width: 100%; padding: 12px; font-size: 15px; }
.login-error { color: var(--red); font-size: 13px; margin-bottom: 10px; }
.login-error.hidden { display: none; }
.login-hint { color: var(--muted); font-size: 12px; margin-top: 16px; line-height: 1.7; }

/* 侧边栏用户信息 */
.user-chip { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; }
.user-chip-info { min-width: 0; }
.user-name { display: block; font-size: 13px; font-weight: 600; color: var(--slate); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 11px; color: var(--muted); }

/* 用户管理 / 改密码 */
.user-item .kb-title { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.pw-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pw-row .input { flex: 1; min-width: 140px; }

/* 只读角色隐藏所有写操作按钮 */
body.role-viewer .write-only { display: none !important; }




.alert-card { border-left: 4px solid var(--border); }
.alert-red { border-left-color: var(--red); }
.alert-orange { border-left-color: var(--orange); }
.alert-amber { border-left-color: var(--amber); }
.alert-blue { border-left-color: var(--primary); }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.muted { color: var(--muted); margin-bottom: 12px; }
.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.about { line-height: 2; color: var(--slate); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-box {
  background: #fff;
  border-radius: 16px;
  width: 720px;
  max-width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .3);
}
.modal-small { width: 420px; }
.modal-wide { width: 880px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; }
.modal-close { border: none; background: none; font-size: 16px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-grid label, .modal-body > label { display: block; font-size: 13px; color: var(--slate); }
.form-grid label span { display: block; margin-bottom: 5px; }
.modal-body > label { margin-bottom: 12px; }
.file-status { font-size: 12px; margin-top: 4px; }

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 11px 22px;
  border-radius: 12px;
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 8px 30px rgba(15, 23, 42, .35);
}
.toast.hidden { display: none; }
.toast.error { background: var(--red); }

/* 右下角悬浮智能助手 */
.chat-fab {
  position: fixed;
  right: 26px;
  bottom: 26px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(37, 99, 235, .45);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease;
}
.chat-fab:hover { transform: scale(1.08); box-shadow: 0 14px 36px rgba(37, 99, 235, .55); }
.chat-fab::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(37, 99, 235, .45);
  animation: fab-pulse 2.4s ease-out infinite;
}
.chat-fab.open::after { display: none; }
@keyframes fab-pulse {
  0% { transform: scale(1); opacity: .9; }
  100% { transform: scale(1.55); opacity: 0; }
}
.chat-pop {
  position: fixed;
  right: 24px;
  bottom: 100px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 132px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
  z-index: 95;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop-in .22s ease-out;
}
.chat-pop.hidden { display: none; }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
}
.chat-pop-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-pop-avatar {
  width: 38px;
  height: 38px;
  flex: none;
  background: rgba(255, 255, 255, .18);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
}
.chat-pop-name { font-size: 15px; font-weight: 600; }
.chat-pop-status { font-size: 11px; opacity: .88; }
.chat-pop-close {
  border: none;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  flex: none;
  transition: background .15s;
}
.chat-pop-close:hover { background: rgba(255, 255, 255, .32); }
.chat-pop .chat-messages { padding: 14px 16px 4px; }
.chat-pop .chat-suggestions { padding: 8px 16px 4px; }
.chat-pop-input-row { padding: 10px 16px 14px; margin-top: 0; }
.chat-pop .chip { font-size: 11px; padding: 4px 11px; }
@media (max-width: 600px) {
  .chat-fab { right: 16px; bottom: 16px; width: 54px; height: 54px; font-size: 23px; }
  .chat-pop { right: 10px; left: 10px; width: auto; height: min(560px, calc(100vh - 130px)); bottom: 82px; border-radius: 16px; }
}
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item { width: auto; }
  .sidebar-foot { display: none; }
  .main { padding: 18px 14px 30px; }
  .form-grid { grid-template-columns: 1fr; }
}/* ===== v1.1 新增样式 ===== */
.amount-line { font-size: 16px !important; line-height: 1.4; }
.col-check { width: 34px; text-align: center; }
.col-check input { cursor: pointer; }
td.col-check { padding: 0; }
.total-row td { background: #f1f5f9; font-weight: 700; color: var(--slate); border-top: 2px solid var(--border); }
.ops { white-space: nowrap; }
.ops .btn + .btn { margin-left: 4px; }
.bulk-bar { display: inline-flex; align-items: center; gap: 10px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 4px 10px; font-size: 13px; color: var(--slate); }
.bulk-bar.hidden { display: none; }
.bulk-check { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.bulk-info b { color: var(--primary); }
.backup-list { margin-top: 12px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.backup-row { display: grid; grid-template-columns: 1fr 70px 150px 64px; gap: 8px; align-items: center; padding: 7px 12px; font-size: 13px; border-top: 1px solid var(--border); }
.backup-row:first-child { border-top: none; }
.backup-row:nth-child(even) { background: #f8fafc; }
.backup-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--slate); }
.backup-size, .backup-time { color: var(--muted); }
.backup-empty { padding: 10px 4px; }
/* ===== v1.2 新增样式 ===== */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--primary); background: #f0f6ff; }
.detail-body { max-height: 62vh; overflow-y: auto; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.detail-grid .dt { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.detail-grid .dd { font-size: 14px; color: var(--slate); word-break: break-all; }
.detail-notes { margin-top: 14px; }
.detail-fulltext { margin-top: 16px; border-top: 1px dashed var(--border); padding-top: 14px; }
.detail-fulltext mark { border-radius: 3px; padding: 0 2px; }
.detail-fulltext mark.hl-danger { background: #fee2e2; color: #b91c1c; }
.detail-fulltext mark.hl-warn { background: #fef3c7; color: #b45309; }
.detail-fulltext mark.hl-info { background: #dbeafe; color: #1d4ed8; }
.hl-legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 6px 0 8px; font-size: 12px; color: var(--muted); }
.hl-legend span { display: inline-flex; align-items: center; gap: 5px; }
.hl-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.hl-dot.danger { background: #fecaca; border: 1px solid #f87171; }
.hl-dot.warn { background: #fde68a; border: 1px solid #fbbf24; }
.hl-dot.info { background: #bfdbfe; border: 1px solid #60a5fa; }
.extract-row { margin-top: 6px; display: flex; align-items: center; gap: 10px; }
.fulltext-toolbar { display: flex; gap: 8px; margin: 10px 0 6px; }
.doc-preview h4 { text-align: center; margin: 0 0 10px; font-size: 16px; }
.doc-preview-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 12px; }
.doc-preview-meta b { margin-right: 4px; }
.doc-preview-text { font-size: 13px; line-height: 1.9; color: var(--slate); white-space: pre-wrap; word-break: break-all; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; max-height: 58vh; overflow-y: auto; }
.tpl-inline { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: #fbfdff; }
.tpl-inline-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.tpl-inline-title { font-weight: 600; font-size: 14px; }
.tpl-inline-head label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.tpl-inline-head .input { width: 200px; }
.tpl-inline-preview { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 10px; }
.tpl-inline-preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.tpl-pick-filter { margin: 8px 0 10px; }
.tpl-pick-filter label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.tpl-pick-filter .input { width: 220px; }
.tpl-preview-text { margin: 0; white-space: pre-wrap; word-break: break-all; font-size: 13px; line-height: 1.8; color: var(--slate); background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; max-height: 60vh; overflow-y: auto; }
.detail-notes .dt { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.detail-notes p { margin: 0; font-size: 13px; color: var(--slate); background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; line-height: 1.7; white-space: pre-wrap; word-break: break-all; }
/* ===== v2.0 新增样式 ===== */
.settings-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.snav { border: 1px solid var(--border); background: #fff; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--slate); }
.snav:hover { border-color: var(--primary); color: var(--primary); }
.snav.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.snav-panel { display: none; }
.snav-panel.active { display: block; }
.provider-list { display: grid; gap: 12px; margin-top: 12px; }
.provider-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.provider-card.active { border-color: var(--primary); background: #f8fbff; box-shadow: 0 0 0 1px var(--primary); }
.pc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; flex-wrap: wrap; }
.pc-name { font-weight: 700; color: var(--slate); }
.pc-type { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 10px; padding: 1px 8px; }
.pc-active { color: var(--green); font-weight: 600; font-size: 13px; }
.pc-actions { display: flex; align-items: center; gap: 10px; }
.pc-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.pc-body label { display: block; font-size: 12px; color: var(--muted); }
.pc-foot { margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.pc-result { font-size: 12px; }
.kb-list { margin-top: 10px; display: grid; gap: 10px; }
.kb-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.kb-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kb-title { font-weight: 700; color: var(--slate); }
.kb-cat { font-size: 11px; color: var(--primary); background: #eff6ff; border-radius: 10px; padding: 1px 8px; margin-left: 6px; }
.kb-tags { margin: 6px 0 0; }
.kb-content { font-size: 13px; color: var(--slate); margin-top: 6px; line-height: 1.7; white-space: pre-wrap; }
.chip-mini { display: inline-block; font-size: 11px; background: #f1f5f9; border-radius: 10px; padding: 1px 8px; margin-right: 4px; color: var(--muted); }
.skill-list { display: grid; gap: 10px; margin-bottom: 12px; }
.skill-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.skill-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.skill-name { font-weight: 700; color: var(--slate); }
.skill-ops { display: flex; align-items: center; gap: 8px; }
.skill-prompt { font-size: 13px; color: var(--slate); margin-top: 6px; line-height: 1.6; }
.skill-meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.mcp-list { display: grid; gap: 10px; margin-bottom: 12px; }
.mcp-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; flex-wrap: wrap; }
.mcp-name { font-weight: 700; color: var(--slate); }
.mcp-desc { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-all; }
.mcp-err { font-size: 12px; color: var(--red); margin-top: 4px; }
.mcp-ops { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.check-line { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 14px; color: var(--slate); }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.switch input { display: none; }
.switch .slider { width: 34px; height: 18px; background: #cbd5e1; border-radius: 18px; position: relative; transition: background .2s; }
.switch .slider::after { content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: left .2s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::after { left: 18px; }

.tpl-var { display: inline-block; margin: 2px 4px 2px 0; padding: 2px 8px; border: 1px solid var(--border,#d8dee4); border-radius: 10px; font-size: 12px; cursor: pointer; user-select: none; background: var(--bg,#f6f8fa); }
.tpl-var:hover { border-color: var(--primary,#2563eb); color: var(--primary,#2563eb); }
.sch-runs-title { margin-top: 12px; }

.review-box .modal-body { max-height: 60vh; overflow: auto; }
.rv-item { padding: 6px 0; border-bottom: 1px dashed var(--border,#e5e7eb); line-height: 1.6; }
.rv-tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; margin-right: 6px; }
.rv-danger { background: #fee2e2; color: #b91c1c; }
.rv-warn { background: #fef3c7; color: #b45309; }
.rv-ok { background: #dcfce7; color: #15803d; }
.rv-info { background: #e0f2fe; color: #0369a1; }
#review-body { white-space: normal; }
#review-body.llm-text { white-space: pre-wrap; }

/* 打印样式 */
#print-area { display: none; }
@media print {
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing #print-area {
    display: block !important;
    position: absolute; left: 0; top: 0; width: 100%;
    padding: 20px; color: #111; background: #fff;
  }
  #print-area .print-title { text-align: center; font-size: 18px; margin-bottom: 14px; }
  #print-area .detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 16px; margin-bottom: 14px; }
  #print-area .detail-grid .dt { display: block; font-size: 11px; color: #888; }
  #print-area .detail-grid .dd { font-size: 13px; }
  #print-area .print-body { font-size: 13px; line-height: 1.8; white-space: pre-wrap; word-break: break-word; }
  #print-area mark.hl-danger { background: #fecaca; color: #991b1b; }
  #print-area mark.hl-warn { background: #fef08a; color: #854d0e; }
  #print-area mark.hl-info { background: #bfdbfe; color: #1e40af; }
}

/* 语音识别面板 */
.snav-panel .card > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.snav-panel .card > label.row-label { display: flex; align-items: center; gap: 8px; color: var(--slate); font-size: 13px; }

/* ===== 智能体全流程引导 ===== */
#guide-card { padding: 18px 20px 16px; }
.guide-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.guide-head h3 { margin: 0 0 6px; font-size: 16px; }
.guide-sub { color: var(--muted); font-size: 12.5px; line-height: 1.7; max-width: 900px; }
#guide-card.guide-collapsed #guide-body { display: none; }
.flow-scroll { overflow-x: auto; padding: 2px 2px 10px; }
.flow-steps { display: flex; align-items: stretch; gap: 10px; min-width: 1060px; }
.flow-arrow { align-self: center; color: #94a3b8; font-size: 19px; flex: 0 0 auto; user-select: none; }
.flow-step {
  flex: 1 1 0; min-width: 158px; max-width: 195px;
  display: flex; flex-direction: column; gap: 7px;
  padding: 14px 14px 12px; text-align: left; cursor: pointer;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 12px;
  font-family: inherit; position: relative; overflow: hidden;
  transition: transform .12s, box-shadow .12s, border-color .12s, background .12s;
}
.flow-step::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--primary), #6366f1); opacity: .85;
}
.flow-step:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(37,99,235,.12); border-color: var(--primary); background: #fff; }
.fs-no {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(135deg, #2563eb, #4f46e5); color: #fff;
  font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.fs-title { font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.fs-desc { font-size: 12px; line-height: 1.55; color: var(--muted); flex: 1; }
.fs-go { font-size: 12px; color: var(--primary); font-weight: 600; }
.flow-step.disabled, .base-chip.disabled { opacity: .45; cursor: not-allowed; filter: saturate(.25); }
.flow-step.disabled:hover, .base-chip.disabled:hover { transform: none; box-shadow: none; border-color: var(--border); background: #f8fafc; color: inherit; }
.flow-base {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 10px 12px; margin-top: 2px; border-radius: 10px;
  background: #f8fafc; border: 1px dashed var(--border);
}
.base-label { font-size: 12.5px; font-weight: 700; color: var(--slate); margin-right: 2px; }
.base-chip {
  border: 1px solid var(--border); background: #fff; color: var(--slate);
  font-size: 12.5px; font-family: inherit; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
}
.base-chip:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }
.base-hint { font-size: 11.5px; color: var(--muted); margin-left: auto; }

/* 台账高级筛选行 */
.toolbar-sub { margin-top: -8px; padding: 10px 12px; background: #f8fafc; border: 1px dashed var(--border); border-radius: 10px; }
.toolbar-sub .input { max-width: 190px; }
.toolbar-sub .toolbar-label { font-size: 12.5px; color: var(--muted); }
.toolbar-sub .toolbar-tilde { font-size: 12.5px; color: var(--muted); }

/* 工作台卡片标题行 + 客户对账 */
.card-head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head-row h3 { margin: 0; }
#client-report-body table td:first-child { font-weight: 600; }
/* 审批记录时间线 */
.approval-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.approval-item { border-left: 3px solid var(--primary); background: #f8fafc; border-radius: 8px; padding: 8px 10px; }
.approval-item .ap-act { display: inline-block; font-weight: 700; font-size: 12.5px; color: var(--primary); margin-right: 8px; }
.approval-item .ap-meta { font-size: 12px; color: var(--muted); }
.approval-item .ap-comment { font-size: 12.5px; margin-top: 4px; color: var(--slate); }
.approval-item .ap-reject { color: var(--red); }
.approval-item .ap-archive { color: var(--slate); }
.approval-item .ap-submit { color: var(--orange); }
/* 合同变更留痕 */
.change-item { border-left-color: var(--amber); }
.change-old { color: var(--muted); text-decoration: line-through; }
.change-new { color: var(--green); font-weight: 600; }

/* 应收 / 发票对账 */
.recv-sum { display: flex; flex-wrap: wrap; gap: 16px; padding: 10px 14px; margin-bottom: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); font-size: 13px; color: var(--slate); }
.recv-sum b { display: inline-block; margin-left: 4px; font-size: 14px; color: var(--text); }
.recv-line { margin: 4px 0 10px; font-size: 13px; color: var(--slate); }
.recv-line b { font-size: 14px; }
/* 回款计划（分期收款） */
.plan-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 4px; }
.plan-toolbar .muted { font-size: 12.5px; }
.plan-item { border-left-color: var(--primary); }
.plan-ops { display: flex; gap: 8px; margin-top: 6px; }
/* 模板变量校验提示 */
.var-hint { margin: 6px 0 4px; font-size: 12.5px; line-height: 1.7; }
.var-ok { color: var(--green); }
.var-bad { color: var(--red); font-weight: 600; }
.var-tip { color: var(--muted); }
.var-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.var-chip { border: 1px solid var(--border); background: var(--card); color: var(--slate); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; font-family: inherit; }
.var-chip:hover { border-color: var(--primary); color: var(--primary); }

/* ===== 多级审批 / 会签 ===== */
.flow-timeline { display: grid; gap: 10px; }
.ft-head { font-size: 13px; color: var(--slate); background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.ft-item { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; }
.ft-dot { width: 26px; height: 26px; border-radius: 50%; background: #e2e8f0; color: var(--slate); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.ft-active .ft-dot { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px rgba(37, 99, 235, .14); }
.ft-approved .ft-dot { background: var(--green); color: #fff; }
.ft-rejected .ft-dot { background: var(--red); color: #fff; }
.ft-skipped .ft-dot { background: #eef2f7; color: #94a3b8; }
.ft-body { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.ft-active .ft-body { border-color: var(--primary); background: #f8fbff; }
.ft-rejected .ft-body { border-color: var(--red); background: #fff8f8; }
.ft-approved .ft-body { border-color: #bbf7d0; }
.ft-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.ft-tag { font-size: 11px; border-radius: 10px; padding: 1px 8px; background: #eff6ff; color: var(--primary); }
.ft-status { font-size: 11px; border-radius: 10px; padding: 1px 8px; background: #f1f5f9; color: var(--muted); }
.ft-status-active { background: #dbeafe; color: #1d4ed8; }
.ft-status-approved { background: #dcfce7; color: #15803d; }
.ft-status-rejected { background: #fee2e2; color: #b91c1c; }
.ft-meta { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.7; }
.ft-votes { margin-top: 8px; display: grid; gap: 6px; }
.ft-vote { font-size: 12px; color: var(--slate); border-left: 2px solid var(--border); padding-left: 8px; }
.ft-vote-act { font-weight: 700; margin-right: 6px; }
.ft-vote-approve { color: var(--green); }
.ft-vote-reject { color: var(--red); }
.ft-vote-who { margin-right: 6px; }
.flow-chain { font-size: 13px; line-height: 2; }
.flow-nodes-head { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 10px; font-size: 13px; color: var(--slate); }
.flow-nodes { display: grid; gap: 10px; }
.flow-node { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: #fcfdff; }
.flow-node-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.flow-node-no { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.flow-node-head .node-name { flex: 1 1 180px; }
.flow-node-head .node-mode { flex: 0 1 190px; }
.node-approvers { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 8px; }
.node-approvers .check-line { font-size: 12px; }
.node-hint { margin: 6px 0 0; font-size: 12px; }


/* ===== 审批时限 / 超时 / 统计 / 建议 ===== */
.ft-overdue .ft-body { border-color: var(--red); background: #fff7f7; }
.ft-overdue .ft-dot { background: var(--red); color: #fff; box-shadow: 0 0 0 4px rgba(220, 38, 38, .14); }
.ft-status-overdue { background: #fee2e2; color: #b91c1c; font-weight: 700; }
.ft-preview .ft-body { border-style: dashed; background: #fbfcfe; }
.ft-preview .ft-dot { background: #e2e8f0; color: #64748b; }
.stats-block { display: grid; gap: 6px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 6px; }
.stat-mini { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; background: #fbfdff; }
.sm-k { font-size: 12px; color: var(--muted); }
.sm-v { font-size: 18px; color: var(--slate); }
.sm-s { font-size: 12px; color: var(--muted); }
.stats-sub { margin: 14px 0 8px; font-size: 14px; color: var(--slate); }
.table-wrap .muted { margin-bottom: 0; font-size: 11px; }
.node-sla { width: 84px; flex: none; }
.flow-node-head .node-reject { flex: 0 1 178px; }
.flow-node-head .node-esc { width: 84px; flex: none; }
.flow-node-head .node-esc-to { flex: 0 1 168px; }
.flow-node-row2 { margin-top: 8px; }
.node-row-hint { font-size: 12px; }
.ft-history { margin-top: 8px; padding: 8px 10px; border: 1px dashed var(--border); border-radius: 8px; background: #fbfcfe; display: grid; gap: 6px; }
.ft-hist-head { font-size: 12px; color: var(--muted); }
.ft-history .ft-vote { opacity: .78; }
.flow-log-list { display: grid; gap: 10px; max-height: 60vh; overflow: auto; }
.fl-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: #fcfdff; }
.fl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.fl-act { font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 8px; background: #eff6ff; color: var(--primary); }
.fl-act-delete { background: #fef2f2; color: var(--red); }
.fl-act-create { background: #f0fdf4; color: var(--green); }
.fl-name { font-size: 13px; }
.fl-who { color: var(--slate); }
.fl-sum { margin-left: auto; }
.fl-detail { margin: 8px 0 0; padding-left: 18px; color: var(--slate); font-size: 12.5px; line-height: 1.9; }
.chip-ver { background: #eef2ff; color: #4338ca; }
.fl-ops { display: inline-flex; gap: 6px; }
.fl-act-rollback { background: #fff7ed; color: #c2410c; }
.fl-act-restore { background: #f5f3ff; color: #6d28d9; }
.fl-cmp { margin-top: 8px; border: 1px dashed var(--border); border-radius: 8px; padding: 8px 10px; background: #f8fafc; }
.fl-cmp-head { font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--primary); }
.fl-cmp-lines { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.9; color: var(--slate); }
.advice-pre { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 13px; line-height: 1.85; color: var(--slate); background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 14px; max-height: 56vh; overflow: auto; margin: 0; }
