:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --border: #e4e8f0;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eef4ff;
  --green: #16a34a;
  --green-soft: #e7f6ec;
  --amber: #d97706;
  --amber-soft: #fdf3e3;
  --red: #dc2626;
  --red-soft: #fdeaea;
  --gray-soft: #eef1f6;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 8px 30px rgba(16, 24, 40, .10);
}

* { box-sizing: border-box; }

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

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

/* ===== 后台顶部导航 ===== */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 18px; }
.topbar nav a { color: var(--muted); font-size: 14px; padding: 6px 2px; }
.topbar nav a:hover { color: var(--primary); text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 14px; }
.topbar-right .user { color: var(--muted); }

.container { max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }

/* ===== 通用组件 ===== */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card h2 { margin: 0 0 16px; font-size: 17px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-head h1 { font-size: 22px; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
  transition: all .15s;
  background: var(--gray-soft);
  color: var(--text);
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; border-color: var(--border); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-sm { padding: 5px 11px; font-size: 13px; }

/* ===== 统计卡片 ===== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .num { font-size: 26px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 13px; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td {
  text-align: left;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 14px;
}
table.list th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
table.list tr:last-child td { border-bottom: none; }
table.list tr:hover td { background: #fafbfe; }
td.actions { white-space: nowrap; }
td.actions a, td.actions button { margin-right: 4px; }

/* 状态徽标 */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.st-active { background: var(--primary-soft); color: var(--primary); }
.st-done   { background: var(--green-soft);  color: var(--green); }
.st-done-balance { background: #fff1e6; color: #ea580c; }
.st-paused { background: var(--amber-soft);  color: var(--amber); }
.st-todo   { background: var(--gray-soft);   color: var(--muted); }

/* 进度条 */
.bar {
  height: 10px;
  background: var(--gray-soft);
  border-radius: 999px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  border-radius: 999px;
  transition: width .4s ease;
}
.bar.green > i { background: linear-gradient(90deg, #22c55e, #16a34a); }
.progress-cell { min-width: 130px; }
.progress-cell .pct { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ===== 表单 ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field textarea { resize: vertical; min-height: 80px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.alert {
  padding: 11px 15px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error { background: var(--red-soft); color: var(--red); }

/* ===== 里程碑勾选 ===== */
.ms-list { list-style: none; margin: 0; padding: 0; }
.ms-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  background: #fff;
}
.ms-list li.done { background: var(--green-soft); border-color: #d3ecd9; }
.ms-list input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--green); flex-shrink: 0; cursor: pointer; }
.ms-list .ms-title { flex: 1; }
.ms-list li.done .ms-title { color: var(--green); }
.ms-list .ms-time { font-size: 12px; color: var(--muted); }

/* ===== 时间线（客户页 / 动态） ===== */
.timeline { position: relative; margin: 0; padding-left: 26px; list-style: none; }
.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}
.timeline li { position: relative; padding: 0 0 20px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -25px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--primary);
}
.timeline li .t-time { font-size: 12px; color: var(--muted); }
.timeline li .t-text { margin-top: 2px; }

/* ===== 客户页 ===== */
body.customer { background: linear-gradient(180deg, #eef4ff 0%, #f4f6fb 260px); }
.customer-wrap { max-width: 760px; margin: 0 auto; padding: 40px 20px 70px; }
.c-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.c-logo {
  width: 44px; height: 44px; border-radius: 10px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border);
}
.c-logo img { width: 100%; height: 100%; object-fit: contain; }
.c-brand .c-name { font-weight: 700; font-size: 18px; }
.c-brand .c-tag { color: var(--muted); font-size: 13px; }

.c-hero {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 32px 30px;
}
.c-hero h1 { margin: 0 0 6px; font-size: 24px; }
.c-hero .c-customer { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

.big-progress { margin-bottom: 8px; }
.big-progress .pct-row {
  display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px;
}
.big-progress .pct-num { font-size: 44px; font-weight: 800; color: var(--primary); line-height: 1; }
.big-progress .pct-label { color: var(--muted); font-size: 13px; }
.bar.big { height: 14px; }

.c-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 24px 0 4px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.c-meta .meta-label { color: var(--muted); font-size: 12px; }
.c-meta .meta-val { font-weight: 600; font-size: 14px; }

.c-section { margin-top: 26px; }
.c-section h2 { font-size: 16px; margin: 0 0 12px; }

/* 客户页里程碑 */
.c-ms { list-style: none; margin: 0; padding: 0; }
.c-ms li {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 0; border-bottom: 1px dashed var(--border);
}
.c-ms li:last-child { border-bottom: none; }
.c-check {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; margin-top: 2px;
}
.c-ms li.done .c-check { background: var(--green); color: #fff; }
.c-ms li.todo .c-check { background: var(--gray-soft); color: var(--muted); }
.c-ms li.done .c-title { color: var(--green); font-weight: 600; }
.c-ms .c-title { flex: 1; }
.c-ms .c-date { font-size: 12px; color: var(--muted); }

.c-foot {
  text-align: center; color: var(--muted); font-size: 12px;
  margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border);
}

/* 空状态 */
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* 登录页 */
body.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  width: 380px; background: #fff; border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 34px 32px;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; }
.login-card .field { margin-bottom: 14px; }

.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { flex: 1; }

/* 客户链接二维码 */
.qr-box { display: flex; gap: 20px; align-items: center; margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--border); flex-wrap: wrap; }
.qr-box #qrcode { line-height: 0; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.qr-box #qrcode img, .qr-box #qrcode canvas { display: block; }
.qr-side { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.qr-tip { color: var(--muted); font-size: 13px; }

/* ===== 工作看板 ===== */
.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  align-items: start;
}
.board-col {
  background: var(--gray-soft);
  border-radius: 12px;
  padding: 12px;
  min-height: 160px;
}
.board-col h3 {
  margin: 0 0 12px;
  font-size: 14px;
  color: #4b5563;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.col-count {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  padding: 1px 9px;
  color: var(--muted);
}
.board-empty {
  text-align: center;
  color: #b6bfcd;
  font-size: 13px;
  padding: 26px 0;
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.board-card {
  display: block;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  color: var(--text);
  transition: transform .12s, box-shadow .12s;
}
.board-card:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.board-card .name { font-weight: 600; font-size: 14px; }
.board-card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.board-card .bar { height: 7px; }
.board-card .board-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}
.board-card .pct { font-size: 12px; font-weight: 600; color: var(--primary); }
.board-card .ddl { font-size: 11px; color: var(--muted); }
.board-card .ddl.overdue { color: var(--red); font-weight: 600; }
.board-card .ddl.due { color: var(--amber); font-weight: 600; }
.board-card.overdue { border-left-color: var(--red); }
.board-card.due { border-left-color: var(--amber); }

@media (max-width: 900px) {
  .board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .board { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .topbar-inner { gap: 14px; }
}

/* ===== 富文本编辑器 ===== */
.rte { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.rte-toolbar {
  display: flex; flex-wrap: wrap; gap: 2px; align-items: center;
  padding: 6px 8px; border-bottom: 1px solid var(--border); background: #fafbfe;
}
.rte-toolbar button {
  border: 1px solid transparent; background: transparent; border-radius: 6px;
  padding: 4px 9px; font-size: 13px; cursor: pointer; color: var(--text); line-height: 1.4;
}
.rte-toolbar button:hover { background: var(--primary-soft); color: var(--primary); }
.rte-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.rte-editor {
  min-height: 140px; max-height: 420px; overflow-y: auto;
  padding: 12px 14px; font-size: 14px; line-height: 1.7; outline: none;
}
.rte-editor:empty::before { content: attr(data-placeholder); color: #b6bfcd; }
.rte-editor img { max-width: 100%; height: auto; border-radius: 6px; }
.rte-editor h2 { font-size: 16px; margin: 8px 0 4px; }
.rte-editor blockquote { border-left: 3px solid var(--border); margin: 6px 0; padding-left: 12px; color: var(--muted); }
.rte-editor a { color: var(--primary); }

/* ===== 商务信息 / 备注展示 ===== */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.info-item .k { font-size: 12px; color: var(--muted); }
.info-item .v { font-weight: 600; font-size: 15px; margin-top: 2px; }
.info-item .v.money { color: var(--primary); }
.notes-view { font-size: 14px; line-height: 1.7; }
.notes-view img { max-width: 100%; height: auto; border-radius: 6px; margin: 6px 0; }
.notes-view h2 { font-size: 15px; margin: 6px 0 4px; }
.notes-view blockquote { border-left: 3px solid var(--border); margin: 6px 0; padding-left: 12px; color: var(--muted); }
.notes-view:empty::before { content: "（暂无）"; color: #b6bfcd; }

/* 列表页标识标签 */
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.tag-balance { background: #fff1e6; color: #ea580c; }
.tag-promise { background: #fef3c7; color: #b45309; }

/* 看板超时提醒 */
.stale-tag { color: var(--red); font-weight: 600; white-space: nowrap; }

/* 特殊承诺高亮卡片 */
.card-warn { border-left: 4px solid #f59e0b; }
