/* ==========================================================
 * style.css —— Projex 项目管理系统
 * 设计风格：复用 CRM 项目 —— 蓝紫 #4a5cf5 主色、12px 圆角卡片
 * ========================================================== */

:root {
  --brand: #4a5cf5;
  --brand-2: #6b5bd2;
  --brand-hi: #3a4ee8;
  --brand-soft: rgba(74, 92, 245, 0.1);
  --bg: #f5f6fa;
  --card: #ffffff;
  --line: #e5e6ec;
  --line-2: #eef0f5;
  --text: #1f2430;
  --muted: #8a90a2;
  --muted-2: #b0b7c3;
  --success: #14a05a;
  --warning: #e8890c;
  --danger: #d94040;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(30, 35, 60, .06);
  --shadow-lg: 0 8px 32px rgba(30, 35, 60, .12);
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Hiragino Sans GB", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hi); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--text); }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; border: none; background: none; font-size: 14px; }
input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--card);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; min-height: 72px; }
label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
hr { border: none; border-top: 1px dashed var(--line-2); margin: 16px 0; }

/* ============== 通用组件 ============== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.page-head h2 { font-size: 18px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.page-head .sub b { color: var(--text); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  background: var(--brand); color: #fff;
  font-weight: 500;
  transition: background .15s, transform .05s, box-shadow .15s;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-hi); }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: transparent; color: var(--text);
  border-color: var(--line);
}
.btn.ghost:hover { background: var(--bg); border-color: var(--muted-2); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #c03030; }
.btn.sm { padding: 4px 10px; font-size: 13px; border-radius: 6px; }
.btn.block { display: flex; width: 100%; padding: 10px 16px; }
.btn.link { background: transparent; color: var(--brand); padding: 4px 6px; border-radius: 4px; }
.btn.link:hover { background: var(--brand-soft); }
.btn.link.danger { color: var(--danger); }
.btn.link.danger:hover { background: rgba(217, 64, 64, 0.08); }
.btn .icon { font-size: 15px; line-height: 1; }

.stage-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: #f1f3f8;
  border: 1px solid transparent;
  font-size: 12px;
  line-height: 18px;
  font-weight: 500;
  white-space: nowrap;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
  padding: 4px 0;
}
.kv-item { display: flex; flex-direction: column; gap: 4px; }
.kv-item.full { grid-column: 1 / -1; }
.kv-item label { color: var(--muted); font-size: 12px; }
.kv-item .v { color: var(--text); font-size: 14px; word-break: break-all; min-height: 20px; }
.kv-item .v.money { font-variant-numeric: tabular-nums; }
.kv-item .v.money b { color: var(--brand); font-weight: 600; }

/* ============== 登录页 ============== */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at top left, rgba(74, 92, 245, 0.12), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(107, 91, 210, 0.08), transparent 50%),
    var(--bg);
  padding: 32px 16px;
}
.login-box {
  width: 100%; max-width: 400px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}
.login-logo {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .5px;
  margin-bottom: 8px;
}
.login-logo span {
  color: var(--brand);
  background: var(--brand-soft);
  padding: 2px 10px;
  border-radius: 8px;
  font-size: 18px;
  margin-left: 6px;
  letter-spacing: 1px;
}
.login-sub {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 24px;
}
.login-box label {
  display: block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}
.login-box input { margin-top: 6px; }
.login-err {
  background: rgba(217, 64, 64, 0.08);
  color: var(--danger);
  border: 1px solid rgba(217, 64, 64, 0.2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 13px;
}
.login-note {
  margin-top: 16px;
  color: var(--muted-2);
  font-size: 12px;
  text-align: center;
  line-height: 1.6;
}
.demo-accounts { margin: 8px 0 12px; }
.da-title { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.da-item {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--line-2);
  margin-bottom: 6px;
  text-align: left;
  transition: all .15s;
  color: var(--text);
}
.da-item:hover { border-color: var(--brand); background: var(--brand-soft); }
.da-item span { color: var(--muted); font-size: 12px; }

/* ============== 顶栏 ============== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center;
  padding: 0 28px;
  gap: 28px;
}
.topbar .logo {
  font-size: 17px; font-weight: 700; color: var(--text);
  white-space: nowrap;
}
.topbar .logo span {
  color: var(--brand);
  background: var(--brand-soft);
  padding: 1px 10px;
  border-radius: 8px;
  font-size: 14px;
  margin-left: 4px;
  letter-spacing: 1px;
}
.topbar .nav {
  display: flex; align-items: center; gap: 2px; flex: 1;
  overflow-x: auto; scrollbar-width: none;
}
.topbar .nav::-webkit-scrollbar { display: none; }
.topbar .nav button {
  padding: 8px 16px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
  position: relative;
}
.topbar .nav button:hover { background: var(--bg); color: var(--text); }
.topbar .nav button.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.user-box {
  display: flex; align-items: center; gap: 12px;
}
#whoami {
  font-size: 13px;
  color: var(--muted);
}
#whoami b { color: var(--text); font-weight: 600; }

/* ============== 主布局 ============== */
.main {
  display: flex;
  gap: 20px;
  padding: 20px 28px 40px;
  width: 100%;
  max-width: 1920px;
  box-sizing: border-box;
  margin: 0 auto;
  align-items: flex-start;
}
.main .content { flex: 1; min-width: 0; max-width: 100%; overflow-x: clip; }
.main .sidebar-wrap { width: 372px; flex-shrink: 0; position: sticky; top: calc(var(--topbar-h) + 20px); }

.page { display: none; }
.page.active { display: block; }

.admin-only { display: none !important; }
.is-admin .admin-only { display: inline-flex !important; }
.is-admin .admin-only.block { display: flex !important; }
.is-admin td.admin-only, .is-admin th.admin-only { display: table-cell !important; }
.is-admin .admin-only.inline-flex, .is-admin button.admin-only, .is-admin select.admin-only, .is-admin input.admin-only { display: inline-block !important; }

.dept-head-only { display: none !important; }
.is-admin .dept-head-only { display: inline-flex !important; }
.is-dept-head .dept-head-only { display: inline-flex !important; }
.is-admin .dept-head-only.block, .is-dept-head .dept-head-only.block { display: flex !important; }
.is-admin td.dept-head-only, .is-dept-head td.dept-head-only,
.is-admin th.dept-head-only, .is-dept-head th.dept-head-only { display: table-cell !important; }
.is-admin .dept-head-only.inline-flex, .is-dept-head .dept-head-only.inline-flex,
.is-admin button.dept-head-only, .is-dept-head button.dept-head-only,
.is-admin select.dept-head-only, .is-dept-head select.dept-head-only,
.is-admin input.dept-head-only, .is-dept-head input.dept-head-only { display: inline-block !important; }

/* ============== 统计卡片 ============== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
  min-height: 88px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute; top: 0; left: 0; width: 4px; height: 100%;
  background: var(--brand);
  opacity: .6;
}
.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card .value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.5px;
}
.stat-card .unit { color: var(--muted); font-size: 13px; font-weight: 500; margin-left: 2px; }
.stat-card .trend { color: var(--muted); font-size: 12px; }
.stat-card.success::after { background: var(--success); }
.stat-card.warning::after { background: var(--warning); }
.stat-card.danger::after { background: var(--danger); }
.stat-card.purple::after { background: var(--brand-2); }

/* ============== 筛选条 ============== */
.filters {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  padding: 12px 0 4px;
  margin-bottom: 8px;
}
.filters > * { flex-shrink: 0; }
.filters > :first-child { flex: 1; min-width: 200px; }
.filters select { width: 150px; }
.filters input[type="text"], .filters input:not([type]) { width: 100%; max-width: 320px; }

/* ============== 数据表格 ============== */
.table-wrap {
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 8px;
}
/* 项目库专用：强制允许横向滚动 + 显示滚动条 + 右侧可滚阴影提示 */
.page#page-projects .table-wrap,
.proj-table-wrap {
  overflow-x: auto !important;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(74, 92, 245, 0.25) transparent;
}
.page#page-projects .table-wrap::-webkit-scrollbar,
.proj-table-wrap::-webkit-scrollbar {
  height: 10px;
}
.page#page-projects .table-wrap::-webkit-scrollbar-thumb,
.proj-table-wrap::-webkit-scrollbar-thumb {
  background: rgba(74, 92, 245, 0.22);
  border-radius: 999px;
}
.page#page-projects .table-wrap::-webkit-scrollbar-thumb:hover,
.proj-table-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(74, 92, 245, 0.4);
}
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.proj-table { min-width: 1680px; }
.proj-table th,
.proj-table td { white-space: nowrap; }
.data-table thead tr {
  background: #fafbff;
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
  font-size: 13px;
  background: #fafbff;
  position: sticky;
  top: 0;
  z-index: 3;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
  background: #fff;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:hover { background: #f5f7ff; cursor: pointer; }
.data-table tbody tr.no-hover:hover { background: transparent; cursor: default; }
.data-table .ops { display: flex; gap: 6px; flex-wrap: wrap; }
.data-table .ops button { padding: 2px 8px; }
.data-table .name-cell { font-weight: 500; min-width: 180px; }
.data-table .name-cell .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; font-weight: 400; }
.data-table .empty-row td {
  padding: 48px 16px;
  color: var(--muted-2);
  text-align: center;
}

/* ============== 弹窗 ============== */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 22, 36, 0.45);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 5vh 16px;
  animation: fadeIn .18s ease;
  overflow-y: auto;
}
.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  margin: auto 0;
  animation: popIn .22s cubic-bezier(.2, .8, .2, 1);
}
.modal.wide { max-width: 1080px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-2);
}
.modal-head h3 { font-size: 16px; }
.modal-head .close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: 18px; line-height: 1;
}
.modal-head .close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px 22px 8px; max-height: 70vh; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px 20px;
}

/* ========== CRM 详情弹窗 ========== */
.sec-title {
  font-size: 12.5px; font-weight: 600; color: #6b7285;
  margin: 16px 0 9px; padding-bottom: 5px; border-bottom: 1px solid #f0f1f5;
}
.sec-title:first-child { margin-top: 0; }
.detail-body { display: grid; grid-template-columns: 1.05fr .95fr; gap: 22px; }
.detail-left, .detail-right { min-width: 0; }

.stage-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 6px; }
.stage-chip {
  border: 1px solid var(--line-2); background: #fff; color: #5b6175;
  border-radius: 16px; padding: 5px 14px; font-size: 12.5px;
  cursor: pointer; font-family: inherit; transition: .15s;
}
.stage-chip:hover { border-color: var(--c); color: var(--c); }
.stage-chip.on {
  background: var(--c); border-color: var(--c); color: #fff; font-weight: 600;
}

.lead-mini {
  display: flex; align-items: center; gap: 9px; padding: 8px 11px;
  border: 1px solid var(--line-2); border-radius: 8px; margin-bottom: 7px;
  cursor: pointer; transition: .15s; font-size: 13px;
}
.lead-mini:hover { border-color: #c8cdf5; background: #fafbff; }
.lm-title { flex: 1; font-weight: 500; }
.lm-amt { color: #d17800; font-size: 12.5px; }

.follow-add { display: flex; gap: 7px; margin-bottom: 14px; }
.follow-add select { width: 88px; flex-shrink: 0; padding: 7px 8px; border: 1px solid var(--line-2); border-radius: 7px; font-family: inherit; font-size: 13px; }
.follow-add input { flex: 1; padding: 7px 11px; border: 1px solid var(--line-2); border-radius: 7px; font-family: inherit; font-size: 13px; }
.follow-add input:focus, .follow-add select:focus { outline: none; border-color: var(--brand); }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
label.info-full { display: block; margin-top: 10px; }
.sub { display: inline; color: var(--muted); font-size: 13px; font-weight: normal; margin-left: 8px; }
.muted { color: var(--muted); }
.custLeadsMini { display: flex; flex-direction: column; gap: 2px; }

/* 移动端 CRM 详情 */
@media (max-width: 768px) {
  .detail-body { grid-template-columns: 1fr !important; gap: 14px; }
  .detail-left, .detail-right { min-width: 0; }
  .follow-add { flex-wrap: wrap; }
  .follow-add select { width: 100%; }
  .info-grid { grid-template-columns: 1fr; }
}

.empty-state {
  text-align: center;
  padding: 56px 16px;
  color: var(--muted-2);
}
.empty-state .icon { font-size: 40px; margin-bottom: 10px; opacity: .5; }
.empty-state .title { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.empty-state .hint { font-size: 12px; }

/* ============== 侧边栏 AI 对话 ============== */
.ai-panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  height: calc(100vh - var(--topbar-h) - 40px);
  min-height: 520px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.ai-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-2);
  flex-shrink: 0;
}
.ai-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 14px;
}
.ai-title .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(20, 160, 90, 0.12);
  animation: pulse 2s infinite;
}
.ai-mode {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand);
  font-weight: 600;
}
.ai-mode.smart { background: rgba(107, 91, 210, 0.12); color: var(--brand-2); }
.ai-gear {
  width: 28px; height: 28px; border-radius: 6px;
  color: var(--muted); display: flex; align-items: center; justify-content: center;
}
.ai-gear:hover { background: var(--bg); color: var(--text); }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.ai-msg {
  max-width: 92%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.65;
  word-break: break-word;
}
.ai-msg.bot {
  align-self: flex-start;
  background: var(--bg);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.ai-msg.user {
  align-self: flex-end;
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg .tool-chip {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(74, 92, 245, 0.1);
  color: var(--brand);
  margin: 4px 4px 4px 0;
  font-weight: 500;
}
.ai-quick {
  padding: 8px 14px 4px;
  border-top: 1px dashed var(--line-2);
  display: flex; flex-wrap: wrap; gap: 6px;
  flex-shrink: 0;
}
.ai-quick .chip {
  padding: 4px 12px;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text);
  transition: all .15s;
}
.ai-quick .chip:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
}
.ai-input-wrap {
  padding: 10px 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
  border-top: 1px solid var(--line-2);
  flex-shrink: 0;
}
.ai-input {
  position: relative;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  transition: border-color .15s, box-shadow .15s;
}
.ai-input:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.ai-input textarea {
  border: none !important;
  padding: 4px 0;
  box-shadow: none !important;
  min-height: 64px;
  max-height: 240px;
  resize: vertical;
  background: transparent;
  font-size: 13.5px;
  line-height: 1.6;
}
.ai-input textarea:focus { box-shadow: none; }
.ai-input .send {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.ai-input .send:hover { background: var(--brand-hi); }
.ai-input .send:disabled { background: var(--muted-2); cursor: not-allowed; }

/* ============== 时间线（详情右侧） ============== */
.timeline {
  padding: 8px 0 8px 4px;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute; left: 6px; top: 8px; bottom: 8px;
  width: 2px; background: var(--line-2);
}
.tl-item {
  position: relative;
  padding: 6px 0 12px 28px;
}
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: 0; top: 10px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff;
  border: 2px solid var(--brand);
  box-sizing: border-box;
}
.tl-dot.gray { border-color: var(--muted-2); background: var(--muted-2); }
.tl-dot.green { border-color: var(--success); background: #fff; }
.tl-dot.orange { border-color: var(--warning); background: #fff; }
.tl-dot.blue { border-color: #3a7bff; background: #fff; }
.tl-dot.purple { border-color: var(--brand-2); background: #fff; }
.tl-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px; margin-bottom: 4px;
}
.tl-head .meta { color: var(--muted); font-size: 12px; }
.tl-head .type-tag {
  font-size: 11px; padding: 1px 8px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand);
  font-weight: 500;
}
.tl-body { color: var(--text); font-size: 13.5px; line-height: 1.6; }

/* ============== Toast ============== */
.toast {
  position: fixed;
  top: calc(var(--topbar-h) + 18px);
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(30, 35, 60, 0.92);
  color: #fff;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============== 进度条 ============== */
.progress {
  height: 6px; border-radius: 999px; background: var(--line-2);
  overflow: hidden;
}
.progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: 999px;
  transition: width .3s;
}

/* ============== 详情分栏 ============== */
.detail-split {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
  align-items: stretch;
}
.detail-split .left, .detail-split .right {
  display: flex; flex-direction: column; gap: 16px;
  min-width: 0;
}
.detail-card-title {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
  gap: 12px;
}
.detail-card-title h4 { font-size: 15px; }
.detail-card-title .sum {
  font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.detail-card-title .sum b { color: var(--brand); font-weight: 600; }

.section-stage-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 4px 0 12px;
  border-bottom: 1px dashed var(--line-2);
  margin-bottom: 16px;
}
.section-stage-row .group {
  display: flex; align-items: center; gap: 6px;
  padding-right: 14px; border-right: 1px dashed var(--line-2); margin-right: 8px;
}
.section-stage-row .group:last-child { border-right: none; margin-right: 0; }
.section-stage-row .group .label { color: var(--muted); font-size: 12px; }
.section-stage-row .chip {
  padding: 3px 10px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: all .12s;
}
.section-stage-row .chip:hover { background: var(--bg); }
.section-stage-row .chip.active {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: transparent;
  font-weight: 600;
}

/* ============== Tab 组件（详情内切） ============== */
.tabs-row {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 16px;
}
.tabs-row button {
  padding: 10px 18px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: 13.5px;
}
.tabs-row button.active { color: var(--brand); border-color: var(--brand); }

/* ============== Pagination ============== */
.pagination {
  display: flex; justify-content: flex-end; align-items: center;
  gap: 8px; padding: 14px 2px 0;
  color: var(--muted); font-size: 13px;
}
.pagination button {
  padding: 4px 12px; border-radius: 6px;
  border: 1px solid var(--line-2);
  color: var(--text); background: var(--card);
}
.pagination button:hover:not(:disabled) { background: var(--bg); border-color: var(--brand); color: var(--brand); }
.pagination button:disabled { color: var(--muted-2); cursor: not-allowed; }

/* ============== 动画 ============== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(20, 160, 90, 0.12); }
  50%      { box-shadow: 0 0 0 8px rgba(20, 160, 90, 0.06); }
}

/* ============== 设置页：阶段配置卡片（修复遮挡与布局混乱） ============== */
.stages-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.stage-card {
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 14px 18px 16px;
}
.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.stage-head h3 {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.stage-head .sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

/* 阶段表格：紧凑列 + 输入框不撑破布局 */
.stage-card .table-wrap {
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.stage-table {
  width: 100%;
  table-layout: auto;
  border-collapse: collapse;
  font-size: 13px;
}
.stage-table thead tr { background: #fafbff; }
.stage-table th,
.stage-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-2);
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
  white-space: nowrap;
}
.stage-table tbody tr:last-child td { border-bottom: none; }
.stage-table tbody tr:hover { background: rgba(74, 92, 245, 0.03); }
.stage-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12.5px;
  white-space: nowrap;
}
.stage-table .col-ord  { width: 72px; }
.stage-table .col-key  { width: 92px; }
.stage-table .col-name { width: 180px; min-width: 140px; }
.stage-table .col-col  { width: 76px; }
.stage-table .col-pre  { width: 120px; }
.stage-table .col-ops  { width: 80px; text-align: center; }

.stage-table .key-txt {
  display: inline-block;
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  background: #f4f5fa;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.builtin-tag {
  color: var(--muted-2);
  font-size: 12px;
}
.stage-table input.st-ord {
  width: 100%;
  padding: 4px 6px;
  font-size: 12.5px;
  text-align: center;
  min-height: 28px;
  height: 28px;
}
.stage-table input.st-lab {
  width: 100%;
  padding: 4px 8px;
  font-size: 13px;
  min-height: 28px;
  height: 28px;
}
.stage-table input.st-col {
  width: 44px;
  height: 28px;
  padding: 1px;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
}
.stage-table .col-pre .stage-badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stage-table .col-ops { white-space: nowrap; }

@media (min-width: 1560px) {
  .stages-grid { grid-template-columns: 1fr 1fr; gap: 16px; }
}

/* ============== 响应式 ============== */
@media (max-width: 1440px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1240px) {
  .main { flex-direction: column; padding: 16px; }
  .main .sidebar-wrap { width: 100%; position: static; }
  .ai-panel { height: 460px; min-height: 360px; }
  .detail-split { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .topbar { padding: 0 16px; gap: 16px; }
  .topbar .logo { font-size: 15px; }
  .topbar .nav button { padding: 6px 10px; font-size: 13px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .kv-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .modal { max-width: 100%; }
  .main { padding: 12px; }
  .filters select { width: 130px; }
}
@media (max-width: 560px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
}

/* 项目列表操作列适当压缩：保持 4 个按钮（跟进/回款/开票/编辑）一行完整显示，
   只比默认略紧凑，让项目名/客户/金额等字段列多获得一些空间，减少横向滚动。*/
table.data-table td.col-ops,
table.data-table th.col-ops {
  white-space: nowrap;
  padding-left: 10px !important;
  padding-right: 10px !important;
  min-width: 200px !important;   /* 足够放下 跟进+回款+开票+编辑 4 个按钮一行 */
  width: auto !important;        /* 去掉 width:1% —— 会把列压成一条细线 */
}
table.data-table td.col-ops .btn.link {
  padding: 4px 10px !important;  /* 默认 .btn.link 是 6px 14px → 略缩小 */
  font-size: 13.5px !important;
  line-height: 1.5 !important;
  border-radius: 6px;
  margin-left: 0 !important;
  margin-right: 4px !important;   /* 按钮之间 4px 紧凑间距（默认 8px）*/
}
table.data-table td.col-ops .btn.link:last-child {
  margin-right: 0 !important;
}
/* 小屏（≤1440px）再略收紧一点，但保持按钮文字可见 */
@media (max-width: 1440px) {
  table.data-table td.col-ops,
  table.data-table th.col-ops {
    min-width: 180px !important;
  }
  table.data-table td.col-ops .btn.link {
    padding: 3px 8px !important;
    font-size: 13px !important;
    margin-right: 3px !important;
  }
}
.tag-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  background: var(--card);
}
.tag-row:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.tag-row .tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 4px 2px 10px;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
}
.tag-row .tag .x {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--brand); font-weight: 700; cursor: pointer; line-height: 1;
}
.tag-row .tag .x:hover { background: var(--brand); color: #fff; }
.tag-row input { position: relative; }
.tag-row .tag-input {
  flex: 1; min-width: 160px;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 4px 6px !important;
  background: transparent !important;
  font-size: 13px;
}
.tag-row .dd {
  position: absolute;
  top: calc(100% + 4px); left: 0; right: 0;
  max-height: 240px; overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 20;
  padding: 4px;
}
.tag-row .dd .dd-item {
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.tag-row .dd .dd-item:hover { background: var(--bg); color: var(--brand); }
.tag-row .dd .dd-item.disabled { color: var(--muted-2); cursor: not-allowed; opacity: .6; }

.tag-row .dd .dd-item.member-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 2px;
}
.tag-row .dd .dd-item.member-item:hover { background: #f0f4ff; color: var(--text); }
.tag-row .dd .dd-item.member-item.disabled { background: #fafafa; }
.mi-avatar {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.mi-main { flex: 1; min-width: 0; }
.mi-name { font-size: 13.5px; font-weight: 600; color: var(--text); line-height: 1.3; }
.mi-meta { display: flex; gap: 6px; margin-top: 2px; flex-wrap: wrap; }
.mi-dept {
  display: inline-block;
  padding: 1px 7px; font-size: 11.5px;
  background: #eef1ff; color: #4a5cf5;
  border-radius: 4px; line-height: 1.6;
}
.mi-role {
  display: inline-block;
  padding: 1px 7px; font-size: 11.5px;
  background: #f0faf3; color: #17a673;
  border-radius: 4px; line-height: 1.6;
}
.mi-check {
  flex: none;
  font-size: 12px; color: #17a673; font-weight: 600;
  padding: 3px 8px; border: 1px solid #cbe9d8; border-radius: 12px;
  background: #f0faf3;
}

.upload-box {
  border: 2px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.upload-box:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}
.upload-box b { color: var(--brand); display: block; margin-top: 4px; font-weight: 600; }

.file-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: #fafbff;
  margin-bottom: 8px;
  gap: 12px;
}
.file-item .fi-info {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
}
.file-item .fi-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.file-item .fi-name {
  font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13.5px;
}
.file-item .fi-meta {
  font-size: 12px; color: var(--muted);
  margin-top: 2px;
}
.file-item .fi-ops { display: flex; gap: 6px; flex-shrink: 0; }

.tl-placeholder {
  padding: 24px 16px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-align: center;
  font-size: 12.5px;
  line-height: 1.8;
}

.proj-table td { white-space: nowrap; }
.proj-table td.proj-name-cell { min-width: 220px; white-space: normal; }
.proj-table .money { font-variant-numeric: tabular-nums; }

/* 项目库 左右 sticky 列：永远可见类型和操作 */
.proj-table th.col-type,
.proj-table td.col-type {
  position: sticky; left: 0; z-index: 4;
  min-width: 84px; width: 84px;
}
.proj-table th.col-type { z-index: 7; background: #fafbff; }
.proj-table td.col-type { background: #fff; box-shadow: 2px 0 6px -2px rgba(20, 22, 36, 0.08); }
.proj-table tbody tr:hover td.col-type { background: #f5f7ff; }
.proj-table .empty-row td.col-type { background: #fff; }

.proj-table th.col-ops,
.proj-table td.col-ops {
  position: sticky; right: 0; z-index: 5;
  min-width: 380px; width: 380px;
}
.proj-table th.col-ops { z-index: 8; background: #fafbff; box-shadow: -2px 0 6px -2px rgba(20, 22, 36, 0.10); }
.proj-table td.col-ops { background: #fff; box-shadow: -3px 0 8px -2px rgba(20, 22, 36, 0.10); }
.proj-table tbody tr:hover td.col-ops { background: #f5f7ff; }

/* CRM 客户/线索库：操作列更紧凑（4按钮 比项目库少），给业务字段更多空间 */
#page-customers .proj-table th.crm-col-ops,
#page-customers .proj-table td.col-ops,
#page-leads .proj-table th.crm-col-ops,
#page-leads .proj-table td.col-ops {
  min-width: 260px !important;
  width: 260px !important;
}
#page-customers .proj-table td.col-ops .btn.link,
#page-leads .proj-table td.col-ops .btn.link {
  padding: 3px 8px !important;
  font-size: 13px !important;
  line-height: 1.45 !important;
  margin-left: 0 !important;
  margin-right: 3px !important;
}
#page-customers .proj-table td.col-ops .btn.link:last-child,
#page-leads .proj-table td.col-ops .btn.link:last-child {
  margin-right: 0 !important;
}
@media (max-width: 1440px) {
  #page-customers .proj-table th.crm-col-ops,
  #page-customers .proj-table td.col-ops,
  #page-leads .proj-table th.crm-col-ops,
  #page-leads .proj-table td.col-ops {
    min-width: 240px !important;
    width: 240px !important;
  }
}

/* CRM 行点击：去掉 .crm-row-click 的 cursor:pointer —— 全局 tbody tr 已设置 hover + cursor */
#page-customers .proj-table tbody tr.crm-row-click,
#page-leads .proj-table tbody tr.crm-row-click { cursor: pointer; }

.proj-table th.col-name,
.proj-table td.col-name { min-width: 220px; width: 220px; }
.proj-table th.col-cat  { min-width: 100px; width: 100px; }
.proj-table th.col-cust { min-width: 132px; width: 132px; }
.proj-table th.col-prio { min-width: 88px;  width: 88px; }
.proj-table th.col-biz  { min-width: 96px;  width: 96px; }
.proj-table th.col-pay  { min-width: 96px;  width: 96px; }
.proj-table th.col-exec { min-width: 96px;  width: 96px; }
.proj-table th.col-mgr  { min-width: 100px; width: 100px; }
.proj-table th.col-sls  { min-width: 92px;  width: 92px; }
.proj-table th.col-money { min-width: 104px; width: 104px; text-align: right; }
.proj-table td.col-money { text-align: right; }
.proj-table th.col-date { min-width: 116px; width: 116px; }

.project-title {
  font-weight: 600; color: var(--text);
  font-size: 14px;
  margin-bottom: 2px;
}
.project-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.section-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

/* 首页快捷操作卡片 — 用户要求：高度适当压缩，放到页面顶部 */
.quick-action {
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 12px 14px 12px;         /* 原来 18/18/16 → 压缩到 12/14/12，高度减少 ~28% */
  display: flex;
  flex-direction: column;
  gap: 4px;                       /* 原来 6px → 4px */
  cursor: pointer;
  transition: all .18s ease;
  background: #fff;
}
.quick-action:hover {
  transform: translateY(-1px);
  border-color: rgba(74, 92, 245, 0.35);
  box-shadow: 0 6px 18px -10px rgba(74, 92, 245, 0.28);
}
.qa-icon {
  width: 32px; height: 32px; border-radius: 8px;    /* 原来 40×40 → 32×32，高度再少 8px */
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; margin-bottom: 2px;             /* 原来 20px / margin-bottom 4px */
}
.qa-name { font-weight: 600; font-size: 14px; }     /* 原来 14.5 → 14 */
.qa-desc { color: var(--muted); font-size: 12px; line-height: 1.5; }   /* 原来 12.5 / 1.6 → 12 / 1.5 */

/* 首页快捷卡片：外层 page-head / padding 也收紧一点 */
.card.home-quick-card { padding: 14px 18px; }   /* 默认 .card 是 20px 24px → 收紧 6px */
.card.home-quick-card .page-head h2 { margin:0; font-size:15px; }     /* 默认 .page-head h2 16px → 15px */
.card.home-quick-card .page-head .sub { font-size:12px; }             /* 默认 12.5px → 12px */

/* 跟进时间线 wrap */
.tl-wrap { position: relative; }
