/* ============================================================
   亿纬达 ExpVia · 内部工作台设计系统 v2.0
   设计原则：专业克制 · 统一节奏 · 清晰的视觉层级
   兼容：保留全部历史 class 契约，仅做视觉升级，不破坏页面结构
   ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-700: #1e40af;
  --primary-bg: #eff6ff;
  --primary-border: #bfdbfe;

  --nav-bg: #0f172a;
  --nav-hover: #1e293b;
  --nav-text: #94a3b8;
  --nav-active-text: #f8fafc;

  --success: #059669;
  --success-bg: #d1fae5;
  --success-border: #a7f3d0;
  --success-text: #065f46;

  --warning: #d97706;
  --warning-bg: #fef3c7;
  --warning-border: #fde68a;
  --warning-text: #92400e;

  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-border: #fecaca;
  --danger-text: #991b1b;

  --info-bg: #eff6ff;
  --info-border: #bfdbfe;
  --info-text: #1e40af;

  --gold: #f59e0b;
  --gold-hover: #d97706;

  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text-strong: #0f172a;
  --text: #334155;
  --text-mid: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
  --shadow-blue: 0 8px 24px rgba(37, 99, 235, .22);

  --space-1: 4px; --space-2: 8px; --space-3: 12px;
  --space-4: 16px; --space-5: 20px; --space-6: 24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }

/* ---------- 顶部导航 ---------- */
.topnav {
  background: var(--nav-bg); color: #fff; display: flex; align-items: center;
  padding: 0 var(--space-5); height: 54px; position: sticky; top: 0; z-index: 100;
  flex-wrap: wrap; gap: 2px;
  box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 4px 16px rgba(15,23,42,.18);
}
.topnav .brand {
  font-weight: 700; font-size: 16px; margin-right: 20px; white-space: nowrap;
  display: flex; align-items: center; gap: 8px; letter-spacing: .2px;
}
.topnav .brand .logo-dot {
  width: 9px; height: 9px; border-radius: 50%; background: linear-gradient(135deg, #60a5fa, #2563eb);
  display: inline-block; box-shadow: 0 0 0 3px rgba(96,165,250,.18);
}
.topnav .nav-links { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.topnav .nav-links a {
  color: var(--nav-text); text-decoration: none; padding: 7px 12px;
  border-radius: var(--radius-sm); font-size: 13px; transition: background .15s, color .15s;
}
.topnav .nav-links a:hover { background: var(--nav-hover); color: #fff; }
.topnav .nav-links a.active { background: var(--primary); color: #fff; font-weight: 600; }
.topnav .user-info { display: flex; align-items: center; gap: 10px; white-space: nowrap; margin-left: 8px; }
.topnav .user-info span { font-size: 12px; color: var(--text-light); }
.topnav .user-info .role-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 20px; background: rgba(96,165,250,.15);
  color: #93c5fd; font-weight: 500;
}
.topnav .user-info a {
  color: var(--gold); text-decoration: none; font-size: 13px; font-weight: 500;
  padding: 4px 10px; border-radius: var(--radius-sm); transition: background .15s;
}
.topnav .user-info a:hover { background: rgba(245,158,11,.12); color: #fbbf24; }

.container { max-width: 1240px; margin: var(--space-5) auto; padding: 0 var(--space-4); }

/* 面包屑 */
.crumb { margin: var(--space-2) 0 var(--space-4); font-size: 13px; color: var(--text-mid); }
.crumb a { color: var(--primary); }
.crumb a:hover { text-decoration: underline; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card-bg); border-radius: var(--radius-lg); padding: var(--space-5);
  margin-bottom: var(--space-4); box-shadow: var(--shadow);
  border: 1px solid rgba(226, 232, 240, .6);
  transition: box-shadow .18s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card h2 {
  font-size: 16px; margin-bottom: var(--space-3); color: var(--text-strong);
  display: flex; align-items: center; gap: 8px; font-weight: 700;
}
.card h2::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: linear-gradient(180deg, #60a5fa, #2563eb); }
.card h3 { font-size: 14px; margin: var(--space-3) 0 var(--space-2); color: var(--text-strong); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border-light); font-size: 13px; vertical-align: top; }
th { background: #f8fafc; color: #475569; font-weight: 600; white-space: nowrap; letter-spacing: .2px; }
tbody tr:nth-child(even) td { background: #fcfdfe; }
tbody tr:hover td { background: #f1f5f9; }
tr:last-child td { border-bottom: none; }
td .muted { color: var(--text-light); font-size: 12px; }

/* 空态 */
.empty { text-align: center; padding: 40px 16px; color: var(--text-light); font-size: 13px; }
.empty::before { content: "📭"; display: block; font-size: 28px; margin-bottom: 8px; opacity: .7; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm); border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; text-decoration: none; background: var(--primary); color: #fff;
  transition: background .15s, transform .1s, box-shadow .15s;
  line-height: 1.4;
}
.btn:hover { background: var(--primary-600); color: #fff; box-shadow: var(--shadow); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 9px; font-size: 11px; }
.btn-lg { padding: 10px 24px; font-size: 14px; border-radius: var(--radius); }
.btn-green { background: var(--success); }
.btn-green:hover { background: #047857; }
.btn-red { background: var(--danger); }
.btn-red:hover { background: #b91c1c; }
.btn-gray { background: #64748b; }
.btn-gray:hover { background: #475569; }
.btn-amber { background: var(--warning); }
.btn-amber:hover { background: #b45309; }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-hover); color: #fff; }
.btn-ghost { background: #fff; color: var(--primary); border: 1px solid var(--primary-border); }
.btn-ghost:hover { background: var(--primary-bg); color: var(--primary-700); box-shadow: none; }
.btn-link { background: none; color: var(--primary); border: none; padding: 4px 8px; }
.btn-link:hover { background: var(--primary-bg); box-shadow: none; transform: none; }

/* ---------- 表单 ---------- */
label { display: block; font-size: 13px; color: #475569; margin: 10px 0 5px; font-weight: 500; }
label .req { color: var(--danger); }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=email], input[type=tel], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; color: var(--text-strong); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}
textarea { min-height: 80px; resize: vertical; }
input[disabled], select[disabled] { background: #f1f5f9; color: var(--text-light); cursor: not-allowed; }
.form-row { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 140px; }
.form-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-inline label { margin: 0; }

/* 搜索条 */
.searchbar { display: flex; gap: var(--space-2); margin-bottom: var(--space-4); flex-wrap: wrap; align-items: center; }
.searchbar input, .searchbar select { width: auto; flex: 1; min-width: 130px; }
.searchbar .btn { flex-shrink: 0; }

/* ---------- 状态标签 ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; line-height: 1.5; }
.badge-green { background: var(--success-bg); color: var(--success-text); }
.badge-red { background: var(--danger-bg); color: var(--danger-text); }
.badge-amber { background: var(--warning-bg); color: var(--warning-text); }
.badge-gray { background: #e2e8f0; color: #475569; }
.badge-blue { background: #dbeafe; color: var(--primary-700); }

/* ---------- 消息 ---------- */
.flash { background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success-text); padding: 11px 16px; border-radius: var(--radius); margin-bottom: var(--space-4); font-size: 13px; }
.flash-err { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger-text); }
.error-box { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger-text); padding: 11px 16px; border-radius: var(--radius); margin-bottom: var(--space-4); font-size: 13px; }
.note { background: var(--info-bg); border: 1px solid var(--info-border); color: var(--info-text); padding: 9px 14px; border-radius: var(--radius); font-size: 13px; line-height: 1.7; }

/* ---------- 统计卡片 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.stat {
  background: #fff; border-radius: var(--radius-lg); padding: var(--space-4);
  box-shadow: var(--shadow); border: 1px solid rgba(226,232,240,.6);
  position: relative; overflow: hidden; transition: box-shadow .18s, transform .18s;
}
.stat:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.stat::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, #60a5fa, #2563eb); }
.stat .num { font-size: 28px; font-weight: 800; color: var(--primary-700); letter-spacing: -.5px; line-height: 1.2; }
.stat .label { color: var(--text-mid); font-size: 12px; margin-top: 4px; }

/* ---------- 问答区 ---------- */
.chat-box { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4); margin-top: var(--space-3); white-space: pre-wrap; line-height: 1.75; font-size: 13px; }
.chat-box .src { font-size: 12px; color: var(--text-mid); margin-bottom: 6px; }
pre { white-space: pre-wrap; word-break: break-word; font-family: inherit; }

/* ---------- 对话工作台（豆包/DSH 式） ---------- */
.chat-layout { display: flex; gap: var(--space-4); align-items: flex-start; }
.chat-side {
  width: 250px; flex-shrink: 0; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-3); max-height: 74vh;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.chat-side-title { font-size: 13px; font-weight: 700; color: var(--text-strong); padding: 4px 6px 10px; }
.chat-conv-list { overflow-y: auto; flex: 1; }
.chat-conv {
  display: flex; align-items: center; justify-content: space-between; padding: 9px 10px;
  border-radius: var(--radius); margin-bottom: 4px; background: #f8fafc;
  border: 1px solid transparent; transition: background .15s;
}
.chat-conv:hover { background: #f1f5f9; }
.chat-conv.active { background: var(--primary-bg); border-color: var(--primary-border); }
.chat-conv-link { flex: 1; text-decoration: none; color: var(--text-strong); min-width: 0; }
.chat-conv-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv-time { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.chat-conv-ops { display: flex; gap: 3px; margin-left: 6px; flex-shrink: 0; }
.chat-main {
  flex: 1; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; min-height: 62vh; box-shadow: var(--shadow); overflow: hidden;
}
.chat-head { padding: 14px 18px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; gap: 10px; }
.chat-head .chat-avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #60a5fa, #2563eb); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.chat-title { font-weight: 700; font-size: 15px; color: var(--text-strong); }
.chat-sub { font-size: 12px; color: var(--text-light); }
.chat-msgs { flex: 1; overflow-y: auto; padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); max-height: 56vh; background: #fbfcfe; }
.msg { max-width: 85%; display: flex; flex-direction: column; }
.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-ai { align-self: flex-start; align-items: flex-start; }
.msg-bubble { padding: 10px 15px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; line-height: 1.75; font-size: 14px; }
.msg-user .msg-bubble { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; border-bottom-right-radius: 4px; box-shadow: 0 2px 8px rgba(37,99,235,.2); }
.msg-ai .msg-bubble { background: #fff; color: var(--text-strong); border: 1px solid var(--border); border-bottom-left-radius: 4px; box-shadow: var(--shadow-sm); }
.msg-tag { font-size: 11px; color: var(--text-light); margin-bottom: 4px; }
.chat-input { padding: 12px 16px; border-top: 1px solid var(--border-light); display: flex; gap: 10px; background: #fff; }
.chat-input input { flex: 1; padding: 11px 15px; border: 1px solid #cbd5e1; border-radius: 20px; font-size: 14px; }
.chat-input input:focus { box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.chat-input .btn { border-radius: 20px; padding: 9px 20px; }
.chat-hints { margin-top: var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); align-items: center; }
.chat-hint { background: #fff; border: 1px dashed #cbd5e1; border-radius: var(--radius); padding: 9px 16px; font-size: 13px; color: var(--text-mid); cursor: pointer; transition: border-color .15s, color .15s; }
.chat-hint:hover { border-color: var(--primary); color: var(--primary-600); }
.chat-input-wrap { padding: 12px 16px; border-top: 1px solid var(--border-light); }
.chat-main.drag-over { border: 2px dashed var(--gold); border-radius: var(--radius-lg); }
.chat-img { max-width: 260px; max-height: 260px; border-radius: var(--radius); margin: 4px 0 6px; display: block; cursor: zoom-in; border: 1px solid var(--border); }

/* ---------- 登录页 ---------- */
.login-wrap {
  max-width: 400px; margin: 90px auto; background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 36px 34px; border: 1px solid rgba(226,232,240,.7);
  position: relative;
}
.login-wrap::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, #60a5fa, #2563eb, #1d4ed8); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.login-wrap h1 { font-size: 20px; text-align: center; margin-bottom: 6px; color: var(--text-strong); }
.login-wrap .login-sub { text-align: center; color: var(--text-mid); font-size: 12px; margin-bottom: var(--space-5); }

/* ---------- 列表与工具 ---------- */
ul.plain { list-style: none; }
ul.plain li { padding: 7px 0; border-bottom: 1px solid var(--border-light); font-size: 13px; }
ul.plain li:last-child { border-bottom: none; }
.muted { color: var(--text-mid); font-size: 12px; }
.mt12 { margin-top: var(--space-3); }
.mb12 { margin-bottom: var(--space-3); }

/* 分页 */
.pagination { display: flex; gap: 4px; margin: var(--space-4) 0; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 5px 11px; border-radius: var(--radius-sm); font-size: 12px;
  border: 1px solid var(--border); color: var(--text); background: #fff;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .cur { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* ---------- 价格矩阵 ---------- */
table.matrix { border-collapse: collapse; font-size: 13px; min-width: 700px; }
table.matrix th, table.matrix td { border: 1px solid var(--border); padding: 7px 9px; text-align: left; }
table.matrix th { background: #f8fafc; font-weight: 600; white-space: nowrap; }
.cell-price { cursor: pointer; color: var(--primary-600); transition: background .12s; }
.cell-price:hover { background: var(--primary-bg); }
.cell-form { background: #f8fafc; border: 1px solid #cbd5e1; border-radius: var(--radius); padding: 11px; width: 240px; text-align: left; }
.cell-form label { font-size: 12px; color: #475569; display: block; margin-bottom: 2px; }
.cell-form input { width: 100%; margin-bottom: 6px; }

/* ---------- 标签页 ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: var(--space-4); flex-wrap: wrap; }
.tabs a {
  padding: 9px 18px; font-size: 13px; color: var(--text-mid); text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s, border-color .15s;
}
.tabs a:hover { color: var(--primary-600); }
.tabs a.active { color: var(--primary-600); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .topnav { height: auto; padding: 8px 12px; }
  .topnav .brand { margin-right: 12px; }
  .chat-layout { flex-direction: column; }
  .chat-side { width: 100%; max-height: 40vh; }
  .container { padding: 0 12px; }
  .stat .num { font-size: 22px; }
}

/* ---------- 对话反馈按钮（知识缺口池） ---------- */
.msg-feedback { margin-top: 6px; text-align: right; }
.msg-feedback .gap-feedback-btn { font-size: 12px; padding: 2px 10px; }
