/* 拓界工作台 · 全局样式（浅色主题，墨绿主色 #1A3C11 / 金 #E6AF00 / 浅绿 #D7F7E1） */
:root {
  --green: #1A3C11;
  --green-2: #2C5A20;
  --gold: #E6AF00;
  --gold-soft: #FDF6E4;
  --mint: #D7F7E1;
  --bg: #F4F6F2;
  --card: #FFFFFF;
  --text: #1F2A1C;
  --muted: #6B7768;
  --line: #E3E8E0;
  --danger: #C0392B;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
a { color: var(--green-2); text-decoration: none; }
button { font-family: inherit; }

/* ---------- 布局 ---------- */
#app { display: flex; min-height: 100vh; }
#sidebar {
  width: 208px; flex: none; background: var(--green); color: #EAF2E6;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.logo { font-size: 18px; font-weight: 700; letter-spacing: 1px; padding: 22px 20px 14px; color: #fff; }
.logo::after { content: ""; display: block; width: 28px; height: 3px; background: var(--gold); margin-top: 8px; border-radius: 2px; }
#nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; margin: 2px 0;
  border-radius: 8px; color: #CFDCC8; cursor: pointer; font-size: 14px;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(230,175,0,.16); color: #FFD873; }
.nav-icon { width: 18px; text-align: center; }
#userbox { padding: 14px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; }
#userbox .u-name { color: #fff; font-weight: 600; }
#userbox .u-actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
#userbox .u-actions span { cursor: pointer; color: #BFD3B9; }
#userbox .u-actions span:hover { color: var(--gold); }

#main { flex: 1; padding: 24px 28px; min-width: 0; }
.page-title { font-size: 20px; font-weight: 700; color: var(--green); margin-bottom: 4px; }
.page-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.loading { color: var(--muted); padding: 60px; text-align: center; }

/* ---------- 通用组件 ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 18px 20px; box-shadow: 0 1px 4px rgba(26,60,17,.06); }
.grid { display: grid; gap: 14px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: var(--green-2); color: var(--green-2); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-2); color: #fff; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #3D2E00; font-weight: 600; }
.btn-gold:hover { background: #d29f00; color: #3D2E00; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }

input, select, textarea {
  font-family: inherit; font-size: 13px; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--green-2); }
textarea { resize: vertical; }

table.tbl { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
.tbl th { background: #F0F4EC; color: var(--green); font-weight: 600; white-space: nowrap; }
.tbl tr:hover td { background: #FAFCF8; }
.tbl td.wrap { max-width: 340px; white-space: normal; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; line-height: 1.4; white-space: nowrap; }
.b-gray   { background: #EEF1EC; color: #5A6657; }
.b-green  { background: var(--mint); color: #14532D; }
.b-gold   { background: var(--gold-soft); color: #8A6A00; }
.b-red    { background: #FCE8E6; color: var(--danger); }
.b-blue   { background: #E7F0FA; color: #1F4E79; }
.b-purple { background: #F0E8F8; color: #6B3FA0; }

.star { color: var(--gold); font-weight: 700; }

/* ---------- 弹窗 ---------- */
#modal-root .mask {
  position: fixed; inset: 0; background: rgba(15,25,12,.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 40px 14px;
}
.modal {
  background: #fff; border-radius: 12px; width: 640px; max-width: 96vw;
  box-shadow: 0 18px 60px rgba(0,0,0,.25); padding: 22px 24px;
}
.modal.wide { width: 860px; }
.modal h3 { color: var(--green); font-size: 16px; margin-bottom: 16px; }
.modal .m-foot { margin-top: 18px; display: flex; justify-content: flex-end; gap: 10px; }
.f-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.f-grid .full { grid-column: 1 / -1; }
.f-item label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.f-item input[type="text"], .f-item input[type="password"], .f-item input[type="number"],
.f-item input[type="date"], .f-item input[type="datetime-local"], .f-item select, .f-item textarea { width: 100%; }
.f-item .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 12px;
  cursor: pointer; user-select: none; background: #fff;
}
.chip.on { background: var(--green); color: #fff; border-color: var(--green); }

#toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast-item { background: var(--green); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast-item.err { background: var(--danger); }

/* ---------- AI 智能指令 ---------- */
.ai-panel { margin-bottom: 18px; border-top: 3px solid var(--gold); }
.ai-title { font-size: 15px; font-weight: 700; color: var(--green); margin-bottom: 10px; }
.ai-spark { color: var(--gold); }
.ai-panel textarea {
  width: 100%; min-height: 76px; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; line-height: 1.6; resize: vertical; background: #FCFDFB;
}
.ai-panel textarea:focus { border-color: var(--gold); background: #fff; }
.ai-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ai-file-chip {
  display: inline-flex; align-items: center; gap: 4px; background: var(--mint);
  color: #14532D; border-radius: 999px; padding: 5px 12px; font-size: 12px; max-width: 240px;
}
.ai-file-chip b { color: #14532D; font-weight: 700; }
.ai-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 10px; flex-wrap: wrap; }
.ai-attach { font-size: 13px; color: var(--green-2); cursor: pointer; padding: 6px 10px; border: 1px dashed var(--green-2); border-radius: 8px; }
.ai-attach:hover { background: var(--mint); }
.ai-hint { font-size: 12px; color: var(--muted); }
#ai-result { margin-top: 12px; }
.ai-loading { color: var(--muted); font-size: 13px; padding: 8px 0; }
.ai-error { color: var(--danger); font-size: 13px; padding: 8px 0; }
.ai-done { font-size: 13px; color: var(--green); margin-bottom: 6px; }
.ai-list { margin-left: 22px; }
.ai-list li { font-size: 13px; line-height: 1.9; color: var(--text); }
.ai-list li::marker { color: var(--gold); font-weight: 700; }

/* ---------- 客户档案附件 ---------- */
.file-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.file-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #FCFDFB;
}
.file-item .f-type { flex: none; }
.file-item .f-body { flex: 1; min-width: 0; overflow: hidden; font-size: 13px; }
.file-item .f-body a { color: var(--green-2); text-decoration: underline; word-break: break-all; }

/* ---------- 仪表盘 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 18px; }
.stat .num { font-size: 30px; font-weight: 700; color: var(--green); }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }
.dash-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.dash-list { max-height: 380px; overflow-y: auto; }
.dash-item { display: flex; justify-content: space-between; gap: 10px; padding: 9px 2px; border-bottom: 1px dashed var(--line); font-size: 13px; }
.funnel-row { display: flex; align-items: center; gap: 8px; margin: 7px 0; font-size: 12px; }
.funnel-label { width: 64px; color: var(--muted); text-align: right; flex: none; }
.funnel-bar { height: 14px; background: var(--green); border-radius: 3px; min-width: 2px; }
.funnel-num { color: var(--muted); }

/* ---------- 日程 ---------- */
.cal-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { text-align: center; padding: 8px 0; font-size: 13px; font-weight: 600; color: var(--green); }
.cal-head.today { background: var(--gold-soft); border-radius: 8px 8px 0 0; }
.cal-day {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  min-height: 130px; padding: 6px; overflow-y: auto;
}
.cal-day.today { border-color: var(--gold); background: #FFFDF5; }
.cal-day.weekend { background: #FAFAF7; }
.ev-chip {
  display: block; border-left: 3px solid var(--green); background: #F1F6EE;
  border-radius: 4px; padding: 4px 6px; font-size: 12px; margin-bottom: 4px; cursor: pointer; line-height: 1.45;
}
.ev-chip:hover { filter: brightness(0.96); }
.ev-chip.tentative { background: repeating-linear-gradient(45deg, #F1F6EE, #F1F6EE 6px, #E9EFE5 6px, #E9EFE5 12px); border-left-style: dashed; }
.ev-chip .t { color: var(--muted); margin-right: 4px; }
.ev-chip .who { color: var(--muted); }
.cal-person-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.cal-person-tabs .chip.on { background: var(--gold); color: #3D2E00; border-color: var(--gold); }

/* ---------- 地图 ---------- */
.map-layout { display: grid; grid-template-columns: 300px 1fr; gap: 14px; }
#amap { height: calc(100vh - 160px); border-radius: var(--radius); }
.map-list { max-height: calc(100vh - 160px); overflow-y: auto; }
.map-item { padding: 10px 8px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 6px; }
.map-item:hover, .map-item.hl { background: var(--mint); }
.map-item .n { font-weight: 600; font-size: 13px; }
.map-item .m { color: var(--muted); font-size: 12px; margin-top: 2px; }
.amap-pin { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: flex; align-items: center; justify-content: center; font-size: 12px; }
.amap-pin span { transform: rotate(45deg); color: #fff; font-weight: 700; }
.pin-cust { background: var(--green); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.pin-chan { background: var(--gold); border: 2px #3D2E00; box-shadow: 0 2px 6px rgba(0,0,0,.3); }

/* ---------- 跟进时间线 ---------- */
.timeline { border-left: 2px solid var(--mint); margin-left: 8px; padding-left: 18px; }
.tl-item { position: relative; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.tl-item::before {
  content: ""; position: absolute; left: -24px; top: 16px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--gold); border: 2px solid #fff;
}
.tl-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.tl-body { font-size: 13px; white-space: pre-wrap; }
.tl-next { font-size: 12px; color: #8A6A00; margin-top: 4px; }

/* ---------- 登录页 ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(145deg, var(--green) 0%, #12290D 100%); }
.auth-card {
  width: 380px; max-width: 92vw; background: #fff; border-radius: 14px; padding: 40px 36px;
  box-shadow: 0 24px 80px rgba(0,0,0,.4);
}
.auth-logo { font-size: 26px; font-weight: 800; color: var(--green); text-align: center; letter-spacing: 2px; }
.auth-slogan { text-align: center; color: var(--gold); font-size: 13px; margin: 10px 0 30px; letter-spacing: 3px; }
.auth-card .form label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
.auth-card .form input { width: 100%; padding: 11px 12px; }
.auth-card .form button { margin-top: 26px; padding: 12px; font-size: 15px; letter-spacing: 6px; }
.auth-err { color: var(--danger); font-size: 13px; margin-top: 12px; text-align: center; min-height: 18px; }

/* ---------- 手机适配 ---------- */
@media (max-width: 900px) {
  #app { flex-direction: column; }
  #sidebar {
    width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 4px;
    padding: 10px 12px;
  }
  .logo { padding: 0 6px; font-size: 15px; }
  .logo::after { display: none; }
  #nav { display: flex; flex-direction: row; padding: 0; overflow-x: auto; flex: 1; }
  .nav-item { padding: 8px 10px; white-space: nowrap; margin: 0; font-size: 13px; }
  .nav-icon { display: none; }
  #userbox { border-top: none; padding: 0 4px; font-size: 12px; display: flex; align-items: center; gap: 6px; }
  #userbox .u-actions { margin: 0; }
  #main { padding: 14px 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-cols { grid-template-columns: 1fr; }
  .f-grid { grid-template-columns: 1fr; }
  .map-layout { grid-template-columns: 1fr; }
  #amap { height: 60vh; }
  .map-list { max-height: 40vh; }
  .tbl-wrap { overflow-x: auto; }
  .cal-grid { grid-template-columns: repeat(1, 1fr); }
  .cal-head { display: none; }
  .cal-day { min-height: 0; }
}
