:root {
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-50: #eff6ff;
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.14);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55;
}
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 登录 ---------- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 55%, #2563eb 100%); }
.login-card { width: 400px; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); padding: 32px; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-sub { color: var(--text-2); margin-bottom: 22px; }
.login-tabs { display: flex; gap: 4px; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.login-tabs button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 8px; color: var(--text-2); font-weight: 600; }
.login-tabs button.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; background: #fff; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 8px;
  padding: 9px 14px; font-weight: 600; background: var(--bg); color: var(--text); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-danger { background: #fef2f2; color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-left { border-radius: 8px 0 0 8px; }
.btn-right { border-radius: 0 8px 8px 0; }
.qr-box { text-align: center; padding: 10px 0; }
.qr-box #qrcode { display: inline-block; padding: 10px; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.qr-box #qrcode img, .qr-box #qrcode canvas { width: 168px; height: 168px; }
.qr-tip { color: var(--text-2); margin-top: 12px; font-size: 13px; }

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 210px; background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid var(--border); }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: #fff; display: flex;
  align-items: center; justify-content: center; font-weight: 800; font-size: 13px; }
.brand-name { font-weight: 700; font-size: 15px; }
.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; color: var(--text-2);
  font-weight: 500; margin-bottom: 3px; cursor: pointer; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-50); color: var(--primary); font-weight: 600; }
.nav-item .nav-ico { width: 18px; text-align: center; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 60px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; padding: 0 24px; }
.topbar-title { font-size: 17px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.mine-toggle { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; cursor: pointer; }
.user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; position: relative; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 13px; overflow: hidden; }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-name { font-weight: 600; font-size: 13px; }
.user-menu { position: absolute; top: 40px; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); min-width: 150px; z-index: 50; overflow: hidden; }
.user-menu div { padding: 9px 14px; cursor: pointer; font-size: 13px; }
.user-menu div:hover { background: var(--bg); }
.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-h h3 { font-size: 15px; font-weight: 700; }
.card-b { padding: 20px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; border-radius: var(--radius); background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow); }
.kpi .kpi-label { color: var(--text-2); font-size: 13px; }
.kpi .kpi-value { font-size: 26px; font-weight: 800; margin-top: 4px; }
.kpi .kpi-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 > .card { min-width: 0; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); font-size: 13px; white-space: nowrap; }
.tbl th { color: var(--text-2); font-weight: 600; background: #fafbfc; position: sticky; top: 0; }
.tbl tbody tr:hover { background: #f9fafb; }
.tbl .link { color: var(--primary); font-weight: 600; cursor: pointer; }
.tbl .muted { color: var(--text-2); }
.tbl .actions { display: flex; gap: 6px; }
.empty { text-align: center; color: var(--text-3); padding: 50px 0; }

/* ---------- 徽标 ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-soft { background: var(--bg); color: var(--text-2); }
.badge-A, .badge-hot { background: #fef2f2; color: #dc2626; }
.badge-B, .badge-warm { background: #fffbeb; color: #d97706; }
.badge-C, .badge-cold { background: #eff6ff; color: #2563eb; }
.badge-D { background: #f3f4f6; color: #6b7280; }

/* ---------- 阶段推进器（箭头色块） ---------- */
.stepper { display: flex; align-items: stretch; gap: 6px; overflow-x: auto; padding: 4px 2px 12px; }
.stepper.clickable .sp-block { cursor: pointer; }
.sp-block { position: relative; flex: 1 0 100px; min-width: 100px; height: 60px; margin-right: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 6px 12px; background: #f1f2f5; color: var(--text-2);
  border-radius: 6px 0 0 6px; transition: transform .15s ease, filter .15s ease; }
.sp-block:last-child { margin-right: 0; }
.sp-block:first-child { border-radius: 6px 0 0 6px; }
.sp-block::after { content: ''; position: absolute; left: 100%; top: 0; width: 0; height: 0; z-index: 1;
  border-top: 30px solid transparent; border-bottom: 30px solid transparent; border-left: 16px solid #f1f2f5; }
.sp-block:last-child::after { display: none; }
.sp-block .sp-name { font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.2; }
.sp-block .sp-pct { font-size: 11px; font-weight: 700; margin-top: 2px; opacity: .8; white-space: nowrap; }
.sp-block.done { background: var(--sc); color: #fff; }
.sp-block.done::after { border-left-color: var(--sc); }
.sp-block.current { background: var(--sc); color: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); }
.sp-block.current::after { border-left-color: var(--sc); }
.sp-block.target { outline: 3px solid var(--sc); outline-offset: 1px; }
.stepper.clickable .sp-block:hover { filter: brightness(1.06); }

.actions-list { list-style: none; }
.actions-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 8px; font-size: 13px; background: #fff; box-shadow: var(--shadow);
  transition: border-color .15s ease, box-shadow .15s ease; }
.actions-list li:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(37, 99, 235, .08); }
.actions-list li.done { background: #f0fdf4; border-color: #bbf7d0; text-decoration: line-through; color: #15803d; }
.actions-list li label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; flex: 1; }
.actions-list input[type=checkbox] { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--primary); flex: none; }

/* ---------- 时间线 ---------- */
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; margin-bottom: 18px; }
.tl-item::before { content: ''; position: absolute; left: -18px; top: 5px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--border); }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-date { font-weight: 600; }
.tl-body { color: var(--text-2); margin-top: 6px; font-size: 13px; white-space: pre-wrap; }
.tl-next { margin-top: 8px; padding: 8px 12px; background: #fffbeb; border-left: 3px solid var(--warning); border-radius: 6px; font-size: 12px; }

/* ---------- 过滤器 ---------- */
.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.filter-head { display: flex; flex-wrap: nowrap; gap: 10px; align-items: center; }
.filter-head .grow { flex: 1; min-width: 0; }
.filter-grid { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filter-grid .field { margin-bottom: 0; min-width: 130px; }
.filter-grid .field input, .filter-grid .field select { width: auto; min-width: 130px; }
.filter-actions { display: flex; gap: 10px; align-items: center; }
.filter-actions .btn { min-width: 88px; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: flex; align-items: center;
  justify-content: center; z-index: 100; padding: 24px; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); }
.modal.max-w { max-width: 640px; }
.modal.wide { max-width: 780px; }
.modal-h { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-h h3 { font-size: 16px; font-weight: 700; }
.modal-close { border: 0; background: transparent; font-size: 22px; color: var(--text-3); line-height: 1; }
.modal-b { padding: 20px 22px; overflow-y: auto; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 11px 16px; border-radius: 9px; background: #1f2937; color: #fff; font-size: 13px; box-shadow: var(--shadow-lg);
  min-width: 200px; animation: slidein .2s ease; }
.toast.success { background: #047857; }
.toast.error { background: #b91c1c; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 详情 ---------- */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.detail-title { font-size: 20px; font-weight: 800; }
.detail-meta { color: var(--text-2); font-size: 13px; margin-top: 6px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.detail-grid .info { background: var(--bg); border-radius: 8px; padding: 11px 13px; }
.detail-grid .info .k { color: var(--text-3); font-size: 12px; }
.detail-grid .info .v { font-weight: 600; margin-top: 3px; word-break: break-all; }

.section-title { font-size: 14px; font-weight: 700; margin: 22px 0 12px; }
.loading { text-align: center; color: var(--text-3); padding: 40px 0; }
.link-btn { color: var(--primary); font-weight: 600; background: none; border: 0; cursor: pointer; }

/* ---------- 移动端卡片列表 / 筛选收起 ---------- */
.mobile-cards { display: none; }
.filter-toggle { display: none; }

.m-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  margin-bottom: 10px; box-shadow: var(--shadow); }
.m-card-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.m-card-title { font-weight: 700; font-size: 15px; line-height: 1.4; }
.m-card-meta { color: var(--text-2); font-size: 12px; margin-top: 6px; line-height: 1.6; word-break: break-all; }
.m-card-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.m-card-actions .btn { flex: 1; min-width: 56px; padding: 6px 8px; font-size: 12px; }

/* ---------- 移动端底部导航 ---------- */
.nav-bottom { display: none; }

.more-sheet { position: fixed; inset: 0; z-index: 120; }
.more-sheet.hidden { display: none; }
.more-sheet-mask { position: absolute; inset: 0; background: rgba(15,23,42,0.45); }
.more-sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; background: #fff; border-radius: 16px 16px 0 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); }
.more-sheet-title { font-weight: 700; padding: 6px 4px 10px; color: var(--text-2); font-size: 13px; }
.more-item { display: flex; align-items: center; gap: 12px; padding: 13px 6px; border-top: 1px solid var(--border); }
.more-item .nav-ico { width: 20px; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .app { display: block; }
  .main { height: 100vh; }
  .content { padding: 14px 12px calc(76px + env(safe-area-inset-bottom)); }
  .topbar { position: sticky; top: 0; z-index: 20; padding: 0 14px; height: 52px; }
  .topbar-title { font-size: 16px; }
  .mine-toggle { font-size: 12px; }
  .user-name { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 13px 14px; }
  .kpi .kpi-value { font-size: 22px; }
  .grid-2 { grid-template-columns: 1fr; gap: 12px; }
  .desktop-only { display: none !important; }
  .mobile-cards { display: block; }
  .filter-toggle { display: inline-flex; flex: none; }
  .filter-head { flex-wrap: nowrap; }
  .filter-head .grow { flex: 1; min-width: 0; }
  .filters .filter-grid, .filters .filter-actions { display: none; }
  .filters.open .filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .filters.open .filter-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .filter-grid .field { min-width: 0; margin-bottom: 0; }
  .filter-grid .field input, .filter-grid .field select { width: 100%; min-width: 0; }
  .filter-actions .btn { width: 100%; min-width: 0; justify-content: center; }
  .sp-block { flex: 1 0 88px; min-width: 88px; height: 56px; padding: 5px 10px; }
  .sp-block::after { border-top: 28px solid transparent; border-bottom: 28px solid transparent; border-left: 14px solid #f1f2f5; }
  .sp-block.done::after, .sp-block.current::after { border-left-width: 14px; }
  .sp-block .sp-name { font-size: 11px; }
  .sp-block .sp-pct { font-size: 10px; }
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal { width: 100%; max-width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal-h { padding: 15px 16px; }
  .modal-b { padding: 16px; }
  .modal-f { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .detail-head { flex-direction: column; }
  .detail-head > div:last-child { width: 100%; }
  .detail-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .nav-bottom { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--border);
    z-index: 60; padding-bottom: env(safe-area-inset-bottom); }
  .nav-b-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px;
    color: var(--text-2); font-size: 11px; cursor: pointer; }
  .nav-b-item.active { color: var(--primary); }
  .nav-b-ico { font-size: 18px; line-height: 1; }
  #toast-root { top: 12px; right: 12px; left: 12px; align-items: stretch; }
  .toast { min-width: 0; }
}