:root {
  --bg: #eef1f6;
  --panel: #ffffff;
  --line: #e1e4e8;
  --text: #1f2329;
  --muted: #8a9299;
  --primary: #2f7cf6;
  --primary-d: #1e63cc;
  --green: #28a745;
  --red: #f04646;
  --orange: #ff8c3e;
  --gray: #9ba3ab;
  --dark: #0d1b2a;
  --sidebar: #0d1b2a;
  --sidebar-hover: #13263d;
  --sidebar-active: #1a3a66;
  --shadow: 0 2px 12px rgba(20, 30, 50, 0.08);
  --radius: 6px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--red); min-height: 18px; font-size: 13px; }

/* 登录 */
.login-overlay {
  position: fixed; inset: 0; background: linear-gradient(135deg, #2f7cf6, #5ea2ff);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.login-card {
  background: #fff; border-radius: 10px; padding: 32px 28px; width: 340px;
  box-shadow: 0 10px 40px rgba(0,0,0,.18); text-align: center;
}
.login-card h2 { margin: 0 0 4px; }
.login-card input {
  width: 100%; padding: 10px 12px; margin: 16px 0 10px; border: 1px solid var(--line);
  border-radius: 6px; font-size: 14px;
}
.login-card button {
  width: 100%; padding: 10px; border: none; border-radius: 6px; background: var(--primary);
  color: #fff; font-size: 15px; cursor: pointer;
}

/* 布局 */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px; background: var(--sidebar); color: #cbd4dc;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.side-brand {
  height: 56px; display: flex; align-items: center; gap: 8px;
  padding: 0 16px; font-size: 15px; font-weight: 600; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.side-brand .icon { font-size: 18px; }
.side-nav { flex: 1; padding: 10px 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; color: #a9b3be; text-decoration: none; font-size: 14px;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; border-left-color: var(--primary); }
.nav-item .icon { font-size: 15px; width: 20px; text-align: center; }
.side-user {
  padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.side-user .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.side-user .info { line-height: 1.4; }
.side-user .name { color: #fff; font-weight: 500; }
.side-user .role { color: #8a9299; font-size: 11px; }
.side-bottom {
  padding: 10px 16px 16px; display: flex; gap: 8px;
}
.side-btn {
  flex: 1; background: rgba(255,255,255,.08); color: #cbd4dc; border: none;
  padding: 7px 0; border-radius: 4px; cursor: pointer; font-size: 12px;
}
.side-btn:hover { background: rgba(255,255,255,.15); }

/* 主内容 */
.main { flex: 1; padding: 0 20px 20px; overflow-y: auto; }
.page-header {
  height: 56px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.page-header h1 { margin: 0; font-size: 18px; font-weight: 600; }

/* 工具栏 */
.page-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin: 16px 0 12px; gap: 12px;
}
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border: none; border-radius: var(--radius); padding: 7px 14px; font-size: 13px;
  cursor: pointer; font-family: inherit; transition: opacity .15s;
}
.btn:hover { opacity: .9; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); opacity: 1; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* 筛选栏 */
.filter-bar { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-input, .filter-select {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 4px; font-size: 13px; min-width: 110px;
}
.filter-input { flex: 1; min-width: 120px; }
.filter-input.date { min-width: 130px; }
.filter-select { min-width: 100px; background: #fff; }

/* 表格 */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f6f8fa; color: var(--muted); font-weight: 600; font-size: 12px; }
tbody tr:hover { background: #f6f8fc; }
.col-id { width: 50px; text-align: center; }
.col-wide { min-width: 160px; max-width: 320px; white-space: normal; }
.col-action { width: 110px; text-align: center; }
.empty { text-align: center; padding: 40px; color: var(--muted); }
#leadTable { table-layout: auto; }
#leadTable td:nth-child(4) { max-width: 220px; }
#leadTable td:nth-child(5) { max-width: 140px; }

/* 状态徽章 */
.badge { display: inline-block; padding: 3px 9px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.st-待分配 { background: #f0f2f5; color: #666; }
.st-已分配 { background: #e6f0ff; color: var(--primary); }
.st-已接单 { background: #e8f8ee; color: var(--green); }
.st-跟进中 { background: #fff3e6; color: var(--orange); }
.st-已成交 { background: #d4edda; color: #1e7e34; }
.st-已作废 { background: #fee2e2; color: var(--red); }

/* 操作按钮 */
.row-actions { display: flex; gap: 6px; justify-content: center; }
.mini {
  border: 1px solid var(--line); background: #fff; border-radius: 4px; padding: 4px 8px;
  font-size: 12px; cursor: pointer; color: var(--text);
}
.mini:hover { border-color: var(--primary); color: var(--primary); }

/* 详情抽屉 */
.drawer {
  position: fixed; top: 0; right: 0; width: 520px; max-width: 92vw; height: 100%;
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: -4px 0 24px rgba(0,0,0,.12);
  z-index: 30; overflow-y: auto; transition: transform .2s;
}
.drawer.hidden { transform: translateX(100%); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.drawer-head h3 { margin: 0; }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(20,30,50,.4); display: flex; align-items: center; justify-content: center; z-index: 40; }
.modal.hidden { display: none; }
.modal-card { background: #fff; border-radius: 8px; padding: 22px; width: 420px; box-shadow: 0 12px 40px rgba(0,0,0,.22); }
.modal-card h3 { margin: 0 0 16px; }
.modal-card label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 12px; }
.modal-card input, .modal-card select, .modal-card textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px; font-size: 13px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* 详情内部 */
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 8px 12px; padding: 16px 18px; }
.kv .k { color: var(--muted); }
.kv input, .kv select { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; font-size: 13px; }
.detail-actions { padding: 0 18px 18px; display: flex; flex-direction: column; gap: 12px; }
.detail-actions > div { border: 1px solid var(--line); border-radius: 6px; padding: 12px; background: #fafbfc; }
.detail-actions label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.detail-actions input, .detail-actions select, .detail-actions textarea { padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; font-size: 13px; }

/* 时间线 */
.timeline { padding: 10px 18px; }
.tl-item { border-left: 2px solid var(--line); padding: 6px 0 6px 14px; margin-left: 6px; position: relative; }
.tl-item::before { content: ""; position: absolute; left: -5px; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }

/* 统计 */
.stats-panel { margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stats-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stats-box h4 { margin: 0 0 12px; font-size: 14px; }
.bar { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.bar .name { width: 80px; color: var(--muted); font-size: 12px; }
.bar .track { flex: 1; height: 8px; background: #eef1f6; border-radius: 4px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--primary); }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1f2329; color: #fff; padding: 10px 18px; border-radius: 6px; z-index: 60; box-shadow: var(--shadow); }
