:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #1a1d23;
  --text-2: #4a5160;
  --muted: #8a94a6;
  --accent: #2f6bff;
  --accent-soft: #eaf0ff;
  --green: #17a673;
  --green-soft: #e6f7f0;
  --blue: #2f6bff;
  --blue-soft: #eaf0ff;
  --yellow: #d98a00;
  --yellow-soft: #fff4e0;
  --orange: #e07b39;
  --orange-soft: #fdeee2;
  --red: #d93838;
  --red-soft: #fdeaea;
  --gray: #8a94a6;
  --gray-soft: #f0f2f5;
  --purple: #7048c8;
  --purple-soft: #f0eafc;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 4px 16px rgba(16, 24, 40, .08);
}

* { 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", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.01em;
}
.brand .sub { font-size: 12px; color: var(--muted); }
.spacer { flex: 1 1 auto; }

.sync-box {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-2);
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gray);
  display: inline-block;
}
.dot.live { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); animation: pulse 2s infinite; }
.dot.err { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .45 } }

.btn {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text-2);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { background: #f7f8fa; border-color: #b9c0cc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2559dd; }
.btn:disabled { opacity: .55; cursor: default; }

.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.switch input { accent-color: var(--accent); cursor: pointer; }

/* ---------- 主体 ---------- */
.wrap { max-width: 1440px; margin: 0 auto; padding: 20px 24px 64px; }

/* 筛选条 */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 4px 13px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.chip:hover { border-color: var(--border-strong); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.filters .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.filters label { font-size: 12px; color: var(--muted); margin-right: -2px; }
.search {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-family: inherit;
  width: 190px;
  outline: none;
  color: var(--text);
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* KPI */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.kpi .k-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi .k-val { font-size: 25px; font-weight: 660; letter-spacing: -.02em; line-height: 1.15; }
.kpi .k-val small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi .k-foot { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.bar-mini {
  height: 4px; border-radius: 999px; background: var(--gray-soft);
  margin-top: 9px; overflow: hidden;
}
.bar-mini > i { display: block; height: 100%; background: var(--green); border-radius: 999px; }

/* 区块 */
.section { margin-bottom: 30px; }
.sec-head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.sec-head h2 { margin: 0; font-size: 15px; font-weight: 640; }
.sec-head .hint { font-size: 12px; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* 项目卡片 */
.proj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}
.proj { padding: 16px 17px 15px; display: flex; flex-direction: column; gap: 11px; }
.proj:hover { box-shadow: var(--shadow-lg); }
.proj-top { display: flex; align-items: flex-start; gap: 10px; }
.proj-name { font-size: 15px; font-weight: 640; letter-spacing: -.01em; }
.proj-alias { font-size: 12px; color: var(--muted); margin-top: 1px; }
.proj-meta { display: flex; flex-wrap: wrap; gap: 6px; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; padding: 2px 9px; border-radius: 999px;
  background: var(--gray-soft); color: var(--text-2); font-weight: 500; white-space: nowrap;
}
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.yellow { background: var(--yellow-soft); color: var(--yellow); }
.pill.orange { background: var(--orange-soft); color: var(--orange); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.gray { background: var(--gray-soft); color: var(--gray); }
.pill.purple { background: var(--purple-soft); color: var(--purple); }
.pill.outline { background: #fff; border: 1px solid var(--border); }

.proj-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: #fafbfc; border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; }
.stat .s-l { font-size: 11px; color: var(--muted); }
.stat .s-v { font-size: 16px; font-weight: 620; margin-top: 1px; }
.stat .s-v small { font-size: 11.5px; font-weight: 500; color: var(--muted); }

.prog { height: 7px; background: var(--gray-soft); border-radius: 999px; overflow: hidden; }
.prog > i { display: block; height: 100%; border-radius: 999px; background: var(--green); transition: width .5s ease; }
.prog-label { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }

.proj-foot { font-size: 11.5px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; }

/* 看板 */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; }
@media (max-width: 1200px) { .kanban { grid-template-columns: repeat(5, minmax(210px, 1fr)); } }
.kcol {
  background: #f8f9fb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 120px;
}
.kcol-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; font-weight: 620; padding: 2px 4px 6px;
}
.kcol-head .cnt { font-size: 11px; color: var(--muted); font-weight: 500; }

.task {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 11px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 7px;
}
.task:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.task-id { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.task-title { font-size: 13px; font-weight: 560; line-height: 1.4; }
.task-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-2); }
.avatar {
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 600; color: #fff; background: var(--accent);
}
.task-note {
  font-size: 11.5px; color: var(--muted); border-top: 1px dashed var(--border);
  padding-top: 6px; margin-top: 1px;
}
.due { font-size: 11.5px; }
.due.late { color: var(--red); font-weight: 560; }

select.mini {
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 11.5px; padding: 2px 5px; font-family: inherit;
  color: var(--text-2); background: #fff; cursor: pointer; outline: none;
}
select.mini:focus { border-color: var(--accent); }
select.mini.busy { opacity: .5; pointer-events: none; }

/* 图表块 */
.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 12px; }
.grid-2b { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 1000px) { .grid-2, .grid-2b { grid-template-columns: 1fr; } }
.panel { padding: 15px 17px 17px; }
.panel h3 { margin: 0 0 3px; font-size: 13.5px; font-weight: 620; }
.panel .p-sub { font-size: 11.5px; color: var(--muted); margin-bottom: 13px; }

.hbar { display: flex; flex-direction: column; gap: 11px; }
.hbar-row { display: grid; grid-template-columns: 74px 1fr 96px; align-items: center; gap: 10px; }
.hbar-name { font-size: 12.5px; font-weight: 560; display: flex; align-items: center; gap: 6px; }
.hbar-track { height: 20px; background: #f4f5f7; border-radius: 6px; overflow: hidden; position: relative; display: flex; }
.hbar-track > i {
  height: 100%; display: block;
  background: linear-gradient(90deg, #6f9bff, #2f6bff);
}
.hbar-track > u {
  position: absolute; left: 0; top: 0; height: 100%;
  background: repeating-linear-gradient(45deg, rgba(23,166,115,.85) 0 6px, rgba(23,166,115,.6) 6px 12px);
  border-radius: 6px;
}
.hbar-val { font-size: 12px; color: var(--text-2); text-align: right; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--muted); margin-top: 12px; flex-wrap: wrap; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

table.matrix { width: 100%; border-collapse: collapse; font-size: 12px; }
table.matrix th, table.matrix td { padding: 7px 8px; text-align: right; border-bottom: 1px solid var(--border); }
table.matrix th:first-child, table.matrix td:first-child { text-align: left; }
table.matrix thead th { font-size: 11px; color: var(--muted); font-weight: 500; }
table.matrix tbody tr:last-child td { border-bottom: none; }
td.cell { font-variant-numeric: tabular-nums; font-weight: 560; }

/* 甘特 */
.gantt { display: flex; flex-direction: column; gap: 5px; }
.gantt-head { display: flex; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 5px; margin-bottom: 3px; }
.gantt-head span { flex: 0 0 auto; text-align: center; }
.g-row { display: grid; grid-template-columns: 220px 1fr 78px; align-items: center; gap: 10px; }
.g-label { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-track { position: relative; height: 18px; background: #f4f5f7; border-radius: 5px; }
.g-bar {
  position: absolute; top: 3px; height: 12px; border-radius: 4px; min-width: 4px;
  background: var(--blue);
}
.g-bar.done { background: var(--green); }
.g-bar.late { background: var(--red); }
.g-bar.todo { background: var(--gray); }
.g-due { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.g-due.late { color: var(--red); }
.today-line { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--red); opacity: .55; }

/* 提示 / 空态 */
.banner {
  background: var(--yellow-soft); border: 1px solid #f2d9a8; color: #7a5200;
  border-radius: var(--radius); padding: 13px 16px; font-size: 13px; margin-bottom: 18px;
  line-height: 1.6;
}
.banner.err { background: var(--red-soft); border-color: #f3c2c2; color: #8f2222; }
.banner code {
  background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px;
}
.empty { color: var(--muted); font-size: 12.5px; padding: 22px; text-align: center; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #1a1d23; color: #fff; padding: 9px 18px; border-radius: 9px;
  font-size: 13px; box-shadow: var(--shadow-lg); z-index: 200; opacity: 0;
  transition: opacity .22s, transform .22s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }

.footnote { font-size: 11.5px; color: var(--muted); margin-top: 26px; text-align: center; }
