:root {
  --bg: #F4F6F8;
  --panel: #FFFFFF;
  --line: #E5E8ED;
  --line-2: #EFF1F4;
  --text: #16191D;
  --muted: #6B7280;
  --muted-2: #9AA1AB;
  --brand: #0E7C66;
  --brand-dark: #0A5F4E;
  --brand-soft: #E8F5F1;
  --nav: #0C2B26;
  --nav-text: #A8BDB8;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --danger: #B42318;
  --danger-soft: #FEE4E2;
  --info: #1D4ED8;
  --info-soft: #E8EEFE;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: var(--text); }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% 0%, #E9F5F1 0%, #F4F6F8 55%);
}
.login-card {
  width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 32px 30px; box-shadow: 0 10px 40px rgba(12, 43, 38, .08);
}
.login-card h1 { font-size: 20px; font-weight: 600; letter-spacing: -.2px; }
.login-card p.sub { color: var(--muted); font-size: 13px; margin-top: 6px; margin-bottom: 22px; }
.login-card .field { margin-bottom: 14px; }
.login-card .err { color: var(--danger); font-size: 12.5px; margin-top: 10px; }

/* ---------- 布局 ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px; background: var(--nav); color: var(--nav-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex: 0 0 216px;
}
.brand {
  padding: 18px 18px 14px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px; background: var(--brand);
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 15px;
}
.brand .name { color: #fff; font-weight: 600; font-size: 14.5px; letter-spacing: .2px; }
.brand .tag { font-size: 11px; color: #6E8781; margin-top: 1px; }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav .group { font-size: 11px; color: #5B736D; padding: 12px 8px 6px; letter-spacing: .5px; }
.nav a.item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px;
  color: var(--nav-text); font-size: 13.5px; margin-bottom: 2px; transition: .12s;
}
.nav a.item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.item.on { background: var(--brand); color: #fff; font-weight: 500; }
.nav a.item .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .45; }
.nav a.item.on .dot { opacity: 1; }

.side-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.07); font-size: 12px; }
.side-foot .u { color: #fff; font-size: 13px; }
.side-foot .r { color: #6E8781; }
.side-foot button {
  margin-top: 8px; width: 100%; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  color: #C9D8D4; padding: 6px; border-radius: 7px;
}
.side-foot button:hover { background: rgba(255,255,255,.1); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 22px; position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 15px; font-weight: 600; }
.topbar .crumb { color: var(--muted-2); font-size: 12.5px; }
.topbar .spacer { flex: 1; }
.mswitch {
  display: flex; align-items: center; gap: 8px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px;
}
.mswitch label { font-size: 12px; color: var(--muted); }
.mswitch select { border: none; background: transparent; font-size: 13px; font-weight: 500; outline: none; max-width: 190px; }

.view { padding: 20px 22px 40px; max-width: 1440px; width: 100%; }

/* ---------- 通用 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-h {
  padding: 14px 16px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 10px;
}
.card-h h3 { font-size: 14px; font-weight: 600; }
.card-h .sub { color: var(--muted); font-size: 12.5px; }
.card-h .spacer { flex: 1; }
.card-b { padding: 16px; }
.card-b.tight { padding: 0; }

.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g21 { grid-template-columns: 2fr 1fr; }
.g12 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g21, .g12 { grid-template-columns: 1fr; } }

.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt20 { margin-top: 20px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 6px 12px; border-radius: 8px; font-size: 13px; transition: .12s; white-space: nowrap;
}
.btn:hover { border-color: #CBD2DA; background: #FAFBFC; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.danger { color: var(--danger); border-color: #F3C7C3; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 3px 9px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; line-height: 19px; background: var(--line-2); color: var(--muted); white-space: nowrap;
}
.badge.green { background: var(--brand-soft); color: var(--brand-dark); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.blue { background: var(--info-soft); color: var(--info); }
.badge.gray { background: #F2F4F7; color: #5B6472; }

.stat { padding: 14px 16px; }
.stat .lab { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat .val { font-size: 26px; font-weight: 600; letter-spacing: -.5px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .val small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.stat .foot { font-size: 12px; color: var(--muted); margin-top: 2px; }
.up { color: #B42318; } .down { color: var(--brand); }

table.tb { width: 100%; border-collapse: collapse; }
table.tb th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px;
  padding: 9px 14px; background: #FAFBFC; border-bottom: 1px solid var(--line-2); white-space: nowrap;
}
table.tb td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tb tr:last-child td { border-bottom: none; }
table.tb tr:hover td { background: #FCFDFD; }
table.tb td.right, table.tb th.right { text-align: right; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; color: var(--muted); }
.input, .field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  background: #fff; outline: none; transition: .12s;
}
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14, 124, 102, .1);
}
/* 只读字段：明确灰底，避免误以为可编辑 */
.field input:disabled, .field select:disabled, .field textarea:disabled,
.input:disabled {
  background: #F4F6F5; color: var(--muted); border-color: #E6EAE8; cursor: not-allowed;
}
textarea { resize: vertical; min-height: 70px; line-height: 1.7; }
.field .hint { font-size: 11.5px; color: var(--muted-2); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button {
  background: none; border: none; padding: 8px 12px; color: var(--muted); font-size: 13.5px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted-2); }
.empty .big { font-size: 15px; color: var(--muted); margin-bottom: 4px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(12, 22, 20, .38); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 60px 20px; overflow: auto;
}
.modal {
  background: #fff; border-radius: 14px; width: 560px; max-width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.modal.wide { width: 820px; }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; }
.modal-h h3 { font-size: 15px; font-weight: 600; }
.modal-b { padding: 18px 20px; max-height: 70vh; overflow: auto; }
.modal-f { padding: 12px 20px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- 图表 ---------- */
.chart-wrap { padding: 6px 4px 0; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); padding: 0 4px 6px; }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

.bar-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.bar-row .nm { width: 86px; color: var(--muted); font-size: 12.5px; }
.bar-row .track { flex: 1; height: 8px; background: #F1F3F5; border-radius: 4px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--brand); border-radius: 4px; }
.bar-row .vv { width: 66px; text-align: right; font-variant-numeric: tabular-nums; font-size: 12.5px; }

.funnel-step { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.funnel-step .bar { height: 26px; background: var(--brand-soft); border-radius: 5px; display: flex; align-items: center; padding-left: 8px; color: var(--brand-dark); font-size: 12px; }
.funnel-step .nm { width: 52px; color: var(--muted); font-size: 12.5px; }
.funnel-step .rate { width: 54px; text-align: right; font-size: 12px; color: var(--muted-2); }

/* ---------- 承接工作台 ---------- */
.inbox { display: grid; grid-template-columns: 290px 1fr 300px; gap: 0; height: calc(100vh - 132px); min-height: 520px; }
.inbox > div { overflow: auto; }
.inbox .list { border-right: 1px solid var(--line); background: #fff; }
.inbox .chat { display: flex; flex-direction: column; background: #F7F9F9; }
.inbox .side { border-left: 1px solid var(--line); background: #fff; padding: 14px; }

.conv-item { padding: 11px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.conv-item:hover { background: #FAFCFB; }
.conv-item.on { background: var(--brand-soft); }
.conv-item .top { display: flex; align-items: center; gap: 6px; }
.conv-item .nm { font-weight: 500; font-size: 13.5px; }
.conv-item .msg { color: var(--muted); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .meta { display: flex; align-items: center; gap: 6px; margin-top: 5px; }

.chat-h { padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.chat-body { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg-row { display: flex; gap: 8px; max-width: 76%; }
.msg-row.me { align-self: flex-end; flex-direction: row-reverse; }
.msg-row .av { width: 28px; height: 28px; border-radius: 50%; background: #DDE7E4; color: var(--brand-dark); display: flex; align-items: center; justify-content: center; font-size: 12px; flex: 0 0 28px; }
.msg-row.me .av { background: var(--brand); color: #fff; }
.bubble { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.msg-row.me .bubble { background: var(--brand); border-color: var(--brand); color: #fff; }
.msg-row.sys { align-self: center; max-width: 100%; }
.msg-row.sys .bubble { background: #EDF1F0; color: var(--muted); font-size: 12px; border: none; }

.chat-in { padding: 10px 14px; background: #fff; border-top: 1px solid var(--line); }
.chat-in textarea { min-height: 62px; }
.quick-replies { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.quick-replies button { background: #F4F7F6; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: #41524E; }
.quick-replies button:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- 线索看板 ---------- */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; }
.kcol { background: #F0F3F3; border-radius: 10px; padding: 8px; min-height: 200px; }
.kcol-h { display: flex; align-items: center; gap: 6px; padding: 4px 6px 8px; font-size: 12.5px; color: #4A5A56; font-weight: 500; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; cursor: pointer; }
.kcard:hover { border-color: #C9D6D2; box-shadow: var(--shadow); }
.kcard .nm { font-weight: 500; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.kcard .nd { color: var(--muted); font-size: 12px; margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kcard .ft { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 11.5px; color: var(--muted-2); }

/* ---------- 其它 ---------- */
.timeline { position: relative; padding-left: 16px; }
.timeline:before { content: ''; position: absolute; left: 4px; top: 4px; bottom: 4px; width: 1px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 14px 0; }
.tl-item:before { content: ''; position: absolute; left: -15px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: #fff; border: 1.5px solid var(--brand); }
.tl-item .t { font-size: 12px; color: var(--muted-2); }
.tl-item .c { font-size: 13px; margin-top: 1px; }

.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { background: #F4F7F6; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: #3E4F4B; }

.hit { background: #FFE3E0; color: var(--danger); border-radius: 3px; padding: 0 2px; }
.alert { border-radius: 8px; padding: 9px 12px; font-size: 12.5px; }
.alert.warn { background: var(--warn-soft); color: #7A3E06; }
.alert.err { background: var(--danger-soft); color: #8A1C13; }
.alert.ok { background: var(--brand-soft); color: var(--brand-dark); }
.alert.info { background: var(--info-soft); color: #15399E; }

.toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #10231F; color: #fff; padding: 9px 14px; border-radius: 9px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 380px;
}
.toast.err { background: #7A1C14; }

.loading { padding: 40px; text-align: center; color: var(--muted-2); }

/* 进度 */
.prog { height: 6px; background: #EEF1F0; border-radius: 3px; overflow: hidden; }
.prog > i { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

.scroll-x { overflow-x: auto; }
