/* ============================== 设计令牌 ============================== */
:root {
  --bg: #f4f6fa;
  --bg-grid: rgba(15, 23, 42, 0.028);
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --surface-3: #f1f4f9;
  --border: #e3e8f0;
  --border-strong: #d3dae6;

  --text: #101828;
  --text-2: #475467;
  --text-3: #8a94a6;

  --brand: #2b5cff;
  --brand-soft: #eaf0ff;
  --brand-deep: #1c3fbf;

  --up: #e0453a;
  --up-soft: #fdecea;
  --down: #17a673;
  --down-soft: #e6f7f1;
  --warn: #e08b1f;
  --warn-soft: #fdf3e2;
  --muted: #97a1b2;
  --muted-soft: #eef1f6;

  --c1: #2b5cff;
  --c2: #17a2b8;
  --c3: #7c5cff;
  --c4: #f2a33c;
  --c5: #e0453a;
  --c6: #17a673;
  --c7: #64748b;
  --c8: #d946a6;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 4px 16px -4px rgba(16, 24, 40, 0.09), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, 0.14);

  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
}

/* ============================== 基础 ============================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 48px 48px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.wrap { max-width: 1520px; margin: 0 auto; padding: 0 28px 72px; }

/* ============================== 顶栏 ============================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1520px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }

.brand-mark {
  width: 42px; height: 42px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 15px;
  letter-spacing: -0.4px;
  box-shadow: 0 4px 12px -2px rgba(43, 92, 255, 0.42);
  flex-shrink: 0;
}

.brand-text { min-width: 0; }
.brand-title { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; white-space: nowrap; }
.brand-sub {
  font-size: 12px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.live-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px 6px 10px;
  border-radius: 999px;
  background: var(--down-soft);
  color: #0d7a55;
  font-size: 12px; font-weight: 600;
  border: 1px solid rgba(23, 166, 115, 0.22);
  white-space: nowrap;
}
.live-pill.stale { background: var(--warn-soft); color: #9a5c05; border-color: rgba(224, 139, 31, 0.28); }
.live-pill.error { background: var(--up-soft); color: #b3352b; border-color: rgba(224, 69, 58, 0.28); }

.pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.82); }
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 自动刷新开关 */
.switch-wrap {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-2); font-weight: 600;
  user-select: none; cursor: pointer;
}
.switch {
  width: 34px; height: 19px; border-radius: 999px;
  background: var(--border-strong); position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 15px; height: 15px; border-radius: 50%;
  background: #fff; transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.switch-wrap.on .switch { background: var(--down); }
.switch-wrap.on .switch::after { transform: translateX(15px); }

/* ============================== 区块标题 ============================== */
.section { margin-top: 30px; }

.section-head {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 14px; padding-left: 2px;
}
.section-num {
  font-size: 11px; font-weight: 800; letter-spacing: 0.8px;
  color: var(--brand); background: var(--brand-soft);
  padding: 3px 8px; border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.section-title { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.section-hint { font-size: 12.5px; color: var(--text-3); margin-left: auto; }

/* ============================== KPI 卡片 ============================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 19px 20px 17px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.kpi::before {
  content: ""; position: absolute; inset: 0 auto 0 0;
  width: 3px; background: var(--accent, var(--brand));
}
.kpi:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.kpi-label {
  font-size: 12.5px; color: var(--text-3); font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 9px;
}
.kpi-dot { width: 7px; height: 7px; border-radius: 2px; background: var(--accent, var(--brand)); flex-shrink: 0; }

.kpi-value {
  font-size: 34px; font-weight: 800; letter-spacing: -1.2px;
  line-height: 1.05; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.kpi-value .unit { font-size: 15px; font-weight: 600; color: var(--text-3); margin-left: 3px; letter-spacing: 0; }

.kpi-foot {
  margin-top: 11px; font-size: 12px; color: var(--text-3);
  display: flex; align-items: center; gap: 7px;
  padding-top: 11px; border-top: 1px dashed var(--border);
}
.kpi-foot b { color: var(--text-2); font-weight: 700; font-variant-numeric: tabular-nums; }

/* 完成率环形 */
.kpi.ring { display: flex; align-items: center; gap: 17px; }
.kpi.ring .kpi-main { flex: 1; min-width: 0; }
.ring-chart { width: 74px; height: 74px; flex-shrink: 0; position: relative; }
.ring-chart svg { transform: rotate(-90deg); display: block; }
.ring-track { stroke: var(--surface-3); }
.ring-bar { stroke: var(--accent, var(--brand)); transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1); }
.ring-center {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 16px; font-weight: 800; letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

/* ============================== 卡片 / 网格 ============================== */
.grid { display: grid; gap: 15px; }
.grid.g2 { grid-template-columns: repeat(2, 1fr); }
.grid.g3 { grid-template-columns: repeat(3, 1fr); }
.grid.g-2-1 { grid-template-columns: 2fr 1fr; }
.grid.g-1-2 { grid-template-columns: 1fr 2fr; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px 18px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  min-width: 0;
}

.card-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 4px;
}
.card-title { font-size: 14.5px; font-weight: 700; letter-spacing: -0.15px; }
.card-note { font-size: 12px; color: var(--text-3); font-weight: 500; margin-left: auto; white-space: nowrap; }
.card-desc { font-size: 12.5px; color: var(--text-3); margin-bottom: 14px; line-height: 1.55; }

.chart-box { position: relative; width: 100%; }
.chart-box canvas { display: block; width: 100% !important; }

.h160 { height: 160px; }
.h200 { height: 200px; }
.h240 { height: 240px; }
.h280 { height: 280px; }
.h320 { height: 320px; }

/* 图例 */
.legend {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  margin-top: 13px; padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.legend-item {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2); font-weight: 600;
}
.legend-swatch { width: 9px; height: 9px; border-radius: 2.5px; flex-shrink: 0; }

/* ============================== 表格 ============================== */
.table-scroll { overflow: auto; max-height: 340px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.table-scroll.tall { max-height: 460px; }

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }

thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-3);
  color: var(--text-2);
  font-weight: 700; font-size: 11.5px;
  text-align: left; letter-spacing: 0.3px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
tbody td {
  padding: 9px 13px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  white-space: nowrap;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr.total td {
  background: var(--brand-soft);
  font-weight: 700; color: var(--brand-deep);
  border-top: 1.5px solid rgba(43, 92, 255, 0.25);
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.name { font-weight: 600; color: var(--text); }
td.strong { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* 负责人胶囊：用品牌色系，与灰色的「项目」标签区分开 */
.owner-chip {
  display: inline-flex; align-items: center;
  padding: 2.5px 9px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-deep);
  font-size: 11.5px; font-weight: 700;
  white-space: nowrap;
}
td .dim { color: var(--text-3); font-size: 12px; }

.rank-no {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 6px;
  background: var(--surface-3); color: var(--text-3);
  font-size: 11px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.rank-no.top { background: var(--brand); color: #fff; }

/* 进度条（表内） */
.bar-cell { display: flex; align-items: center; gap: 9px; min-width: 130px; }
.bar-track {
  flex: 1; height: 7px; border-radius: 999px;
  background: var(--surface-3); overflow: hidden; min-width: 52px;
}
.bar-fill {
  height: 100%; border-radius: 999px;
  background: var(--accent, var(--brand));
  transition: width 0.85s cubic-bezier(0.4, 0, 0.2, 1);
}
.bar-val {
  font-size: 12px; font-weight: 700; color: var(--text-2);
  font-variant-numeric: tabular-nums; min-width: 44px; text-align: right;
}

/* 标签 */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700;
  white-space: nowrap;
}
.tag.dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* 渠道 / 达人清单网格 */
.list-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 9px; max-height: 430px; overflow: auto; padding-right: 4px;
}
.list-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 13px; background: var(--surface-2);
  transition: all 0.16s ease;
}
.list-item:hover { border-color: var(--brand); background: var(--brand-soft); }
.list-item .li-top { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.list-item .li-name {
  font-size: 13.5px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list-item .li-meta {
  font-size: 11.5px; color: var(--text-3);
  display: flex; gap: 9px; flex-wrap: wrap;
}
.list-item .li-meta span { white-space: nowrap; }

/* ============================== 风险预警 ============================== */
.risk-kpi .kpi-value { font-size: 30px; }

/* 风险等级标签 */
.tag.risk-overdue { background: var(--up-soft); color: #b3352b; }
.tag.risk-dueSoon { background: var(--warn-soft); color: #9a5c05; }
.tag.risk-noSchedule { background: var(--muted-soft); color: #5b6675; }

/* 风险清单卡片：左侧色条标识紧急度 */
.list-item.risk { border-left: 3px solid var(--risk-color, var(--muted)); }
.list-item.risk.risk-overdue { --risk-color: var(--up); }
.list-item.risk.risk-dueSoon { --risk-color: var(--warn); }
.list-item.risk.risk-noSchedule { --risk-color: var(--muted); }

.list-item .li-schedule {
  margin-top: 7px; padding-top: 7px;
  border-top: 1px dashed var(--border);
  font-size: 11.5px; color: var(--text-3);
  line-height: 1.6;
  display: flex; flex-direction: column; gap: 2px;
  white-space: normal;
}
.list-item .li-schedule b { color: var(--text-2); font-weight: 600; }
.list-item .li-schedule .due-overdue { color: #b3352b; font-weight: 700; }
.list-item .li-schedule .due-soon { color: #9a5c05; font-weight: 700; }

/* ============================== 备注标注（红标 / 黑标） ==============================
   源表用字体颜色给备注做人工分级，这里沿用同一套语义配色：
   红=需重点关注，黑=特别说明，灰=常规（不展示） */
.list-item.remark { border-left: 3px solid var(--remark-color, var(--muted)); }
.list-item.remark.remark-red { --remark-color: var(--up); }
.list-item.remark.remark-black { --remark-color: #3a4150; }

.tag.remark-red { background: var(--up-soft); color: #b3352b; }
.tag.remark-black { background: rgba(58, 65, 80, 0.1); color: #3a4150; }

/* 备注正文：保留源表的红/黑语义 */
.list-item .li-note {
  margin-top: 7px; padding-top: 7px;
  border-top: 1px dashed var(--border);
  font-size: 12px; line-height: 1.7;
  white-space: normal; word-break: break-word;
}
.remark-red-text { color: #b3352b; font-weight: 700; }
.remark-black-text { color: #3a4150; font-weight: 700; }

/* 表格里的风险状态点 */
.risk-dot {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700;
}
.risk-dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}

/* ============================== 空态 / 骨架 ============================== */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.empty {
  display: grid; place-items: center; height: 100%; min-height: 120px;
  color: var(--text-3); font-size: 13px; text-align: center; padding: 20px;
}

.error-banner {
  display: none;
  margin-top: 18px; padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--up-soft);
  border: 1px solid rgba(224, 69, 58, 0.28);
  color: #b3352b; font-size: 13px; font-weight: 600;
  line-height: 1.6;
}
.error-banner.show { display: block; }
.error-banner code {
  font-family: var(--mono); font-size: 12px;
  background: rgba(179, 53, 43, 0.1); padding: 1px 6px; border-radius: 4px;
}

/* ============================== 页脚 ============================== */
.foot {
  margin-top: 40px; padding-top: 22px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-3);
  display: flex; gap: 18px; flex-wrap: wrap;
  line-height: 1.9;
}
.foot b { color: var(--text-2); font-weight: 600; }

/* ============================== 响应式 ============================== */
@media (max-width: 1240px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid.g-2-1, .grid.g-1-2 { grid-template-columns: 1fr; }
  .grid.g3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .wrap { padding: 0 16px 52px; }
  .topbar-inner { padding: 12px 16px; flex-wrap: wrap; gap: 12px; }
  .brand-sub { display: none; }
  .topbar-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 11px; }
  .kpi { padding: 15px 16px 14px; }
  .kpi-value { font-size: 27px; }
  .grid.g2, .grid.g3 { grid-template-columns: 1fr; }
  .card { padding: 16px 15px 15px; }
  .section-hint { display: none; }
}
@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi.ring { flex-direction: row; }
}

/* 打印 */
@media print {
  body { background: #fff; }
  .topbar { position: static; }
  .btn, .switch-wrap { display: none; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
}
