:root {
  --bg: #0e1220;
  --card: #171d30;
  --card2: #1d2440;
  --line: #2a3354;
  --text: #e6e9f5;
  --muted: #8b93b0;
  --accent: #4f8cff;
  --green: #48bb78;
  --red: #fc8181;
  --orange: #f6ad55;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }

/* ── 侧边栏 ── */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 208px; z-index: 20;
  display: flex; flex-direction: column;
  background: #12172a; border-right: 1px solid var(--line);
}
.side-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px; border-bottom: 1px solid var(--line);
}
.side-logo .logo-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, #4f8cff, #9b7bff);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: #fff;
}
.side-logo .logo-text { display: flex; flex-direction: column; }
.side-logo .lt-main { font-size: 14px; font-weight: 700; }
.side-logo .lt-sub { font-size: 10px; color: var(--muted); }
.side-nav { display: flex; flex-direction: column; gap: 4px; padding: 14px 10px; flex: 1; }
.side-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; font-size: 14px; color: var(--muted);
  transition: background .15s, color .15s;
}
.side-item:hover { color: var(--text); background: rgba(255,255,255,.05); }
.side-item.active { color: #fff; background: linear-gradient(90deg, rgba(79,140,255,.25), rgba(79,140,255,.08)); border: 1px solid rgba(79,140,255,.45); }
.side-item .icon { font-size: 16px; width: 20px; text-align: center; flex: none; }
.side-foot { padding: 14px 16px; font-size: 10px; color: var(--muted); border-top: 1px solid var(--line); line-height: 1.5; }

.main-col { margin-left: 208px; min-height: 100vh; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 28px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(14, 18, 32, .92); backdrop-filter: blur(8px); z-index: 10;
}
.topbar h1 { font-size: 20px; font-weight: 700; }
.subtitle { font-size: 12px; color: var(--muted); margin-left: 10px; }
.topbar-right { display: flex; align-items: center; gap: 18px; }
.today { font-size: 13px; color: var(--muted); }
.nav-link {
  background: var(--card2); border: 1px solid var(--line); color: var(--text);
  padding: 8px 14px; border-radius: 10px; font-size: 13px;
}
.nav-link:hover { border-color: var(--accent); }

.projects { max-width: 1180px; margin: 0 auto; padding: 26px 28px 60px; display: flex; flex-direction: column; gap: 26px; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; font-size: 14px; }

/* ── 项目卡片 ─────────────────────── */
.pcard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 26px;
}
.pcard-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pcard-title { font-size: 18px; font-weight: 700; }
.badge {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid;
}
.badge.run { color: var(--green); border-color: var(--green); background: rgba(72, 187, 120, .12); }
.badge.pre { color: var(--orange); border-color: var(--orange); background: rgba(246, 173, 85, .12); }
.badge.off { color: var(--muted); border-color: var(--muted); background: rgba(139, 147, 176, .12); }
.toggle-start {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  font-size: 11px; padding: 3px 10px; border-radius: 999px; cursor: pointer;
}
.toggle-start:hover { border-color: var(--accent); color: var(--text); }
.toggle-start:disabled { opacity: .5; cursor: wait; }
.pcard-meta { margin-left: auto; font-size: 12px; color: var(--muted); }
.pcard-meta b { color: var(--text); }

/* ── 飞书资料页 ── */
.docs-body { overflow: hidden; }
.docs-main { max-width: 1400px; margin: 0 auto; padding: 14px 24px 24px; display: flex; flex-direction: column; height: calc(100vh - 74px); }
.docs-tabs { display: flex; gap: 8px; flex-wrap: wrap; flex: none; }
.doc-tab {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 14px; cursor: pointer; color: var(--text); font-size: 13px; font-weight: 600;
  transition: border-color .15s, background .15s;
}
.doc-tab:hover { border-color: #5a6a9e; }
.doc-tab.active { border-color: #fff; background: #232c4f; }
.doc-tab .dt-group { font-size: 10px; color: var(--muted); font-weight: 400; }
.doc-tab .dt-desc { font-size: 11px; color: var(--muted); font-weight: 400; }
.docs-hint { font-size: 12px; color: var(--muted); margin: 10px 2px 6px; flex: none; }
.docs-frame-wrap { position: relative; flex: 1; min-height: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card2); }
.docs-frame { width: 100%; height: 100%; display: block; }
.docs-open {
  position: absolute; top: 10px; right: 12px; z-index: 3;
  font-size: 12px; font-weight: 600; color: #0f1428; background: #fff;
  border-radius: 8px; padding: 5px 10px; text-decoration: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.docs-open:hover { background: #e8ecff; }

/* ── 总进度条（阶段顺序铺满，宽度按天数） ── */
.progress-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 20px 0 10px; font-size: 12px; color: var(--muted);
}
.progress-head b { color: var(--text); font-size: 14px; }
.progress-head .ph-sub { margin-left: 8px; font-size: 11px; color: var(--muted); }
.bar-wrap { position: relative; padding-top: 22px; }
.bar {
  display: flex; height: 42px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); background: var(--card2);
}
.bar-seg {
  min-width: 74px; flex-basis: 0; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; color: rgba(255,255,255,.98); text-shadow: 0 1px 2px rgba(0,0,0,.5);
  border-right: 1px solid rgba(0,0,0,.18); overflow: hidden;
}
.bar-seg:last-child { border-right: none; }
.bar-seg .bs-name { font-size: 12px; font-weight: 700; white-space: nowrap; }
.bar-seg .bs-days { font-size: 11px; opacity: .9; white-space: nowrap; }
.bar-seg.cur { box-shadow: inset 0 0 0 3px rgba(255,255,255,.95); }
.bar-seg.cur .bs-name { font-size: 13px; }
.bar-pointer {
  position: absolute; top: 6px; bottom: 0; width: 2px; background: #fff; z-index: 5;
  box-shadow: 0 0 8px rgba(255,255,255,.9); border-radius: 2px;
}
.bp-cap {
  position: absolute; top: -17px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: #0f1428; background: #fff; font-weight: 700;
  padding: 1px 6px; border-radius: 4px; white-space: nowrap;
}
.bar-pointer.at-start .bp-cap { left: 0; transform: none; }
.bar-scale {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--muted); margin-top: 6px;
}

/* ── 当前阶段信息 ─────────────────── */
.current-info {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 16px; padding: 12px 16px; background: var(--card2);
  border: 1px solid var(--line); border-radius: 10px; font-size: 13px;
}
.current-info .cname { font-size: 15px; font-weight: 700; }
.current-info .citem { color: var(--muted); }
.current-info .citem b { color: var(--text); }

/* ── 数据卡 ─────────────────────── */
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.metric {
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
}
.metric .mlabel { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.metric .mlabel a { font-size: 11px; }
.metric .mvalue { font-size: 26px; font-weight: 700; margin-top: 4px; }
.metric .mvalue.na { font-size: 14px; color: var(--muted); font-weight: 400; }
.metric .munit { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 2px; }

.metrics-note { font-size: 11px; color: var(--muted); margin-top: 8px; }
.metrics-note a { font-size: 11px; }

/* 任务统计 chips */
.task-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.tstat {
  font-size: 12px; padding: 5px 12px; border-radius: 999px;
  background: var(--card2); border: 1px solid var(--line); color: var(--muted);
}
.tstat b { color: var(--text); }
.tstat.warn b { color: var(--red); }

/* ── 任务页 ─────────────────────── */
.tasks-main { max-width: 1180px; margin: 0 auto; padding: 22px 28px 60px; }
.tabs { display: flex; gap: 10px; margin-bottom: 16px; }
.tab-btn {
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
  padding: 9px 20px; border-radius: 10px; font-size: 14px; cursor: pointer;
}
.tab-btn.active { color: #fff; border-color: var(--accent); background: rgba(79, 140, 255, .15); }
.tab-btn:disabled { opacity: .45; cursor: not-allowed; }

.summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters { display: flex; gap: 8px; margin-bottom: 16px; }
.filter-btn {
  background: var(--card2); border: 1px solid var(--line); color: var(--muted);
  padding: 6px 14px; border-radius: 8px; font-size: 12px; cursor: pointer;
}
.filter-btn.active { color: #fff; border-color: var(--accent); background: rgba(79, 140, 255, .15); }
.btn-open-feishu {
  margin-left: auto; align-self: center;
  font-size: 13px; font-weight: 600; color: #fff;
  background: linear-gradient(90deg, #4f8cff, #9b7bff);
  border-radius: 10px; padding: 8px 16px; text-decoration: none;
  box-shadow: 0 2px 10px rgba(79, 140, 255, .35);
  transition: filter .15s;
}
.btn-open-feishu:hover { filter: brightness(1.12); }

.task-list { display: flex; flex-direction: column; gap: 8px; }
.stage-group { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stage-group-head {
  display: flex; align-items: center; gap: 10px;
  background: var(--card2); padding: 10px 16px; font-size: 13px; font-weight: 600;
}
.stage-group-head .count { font-weight: 400; font-size: 12px; color: var(--muted); }
.stage-group-body { background: var(--card); }

.trow {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 16px; border-top: 1px solid var(--line); font-size: 13px;
}
.trow:first-child { border-top: none; }
.trow.child { background: rgba(255,255,255,.02); padding-left: 40px; }
.trow.child::before { content: "└"; color: var(--muted); margin-right: -6px; }
.trow.top { margin: 6px 0 2px; background: rgba(79, 140, 255, .06); border-left: 3px solid var(--accent); }
.trow.top > .tbody > .tname { font-size: 14px; font-weight: 800; }
.trow.done .tname { color: var(--muted); text-decoration: line-through; }
.trow.done .tdesc { text-decoration: line-through; }
.tcheck {
  width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--line);
  flex: none; margin-top: 2px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #0e1220; font-weight: 900;
}
.tcheck.checked { background: var(--green); border-color: var(--green); }
.tbody { flex: 1; min-width: 0; }
.tname { font-weight: 600; }
.tdesc { font-size: 12px; color: var(--muted); margin-top: 3px; white-space: pre-wrap; word-break: break-word; line-height: 1.65; }
/* 标题行下的描述：默认两行截断，点击展开为卡片 */
.trow.top > .tbody > .tdesc {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; margin-top: 5px; max-width: 820px; opacity: .9;
}
.trow.top > .tbody > .tdesc.expanded {
  display: block; -webkit-line-clamp: unset; overflow: visible;
  background: rgba(255, 255, 255, .03); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 14px; margin-top: 6px;
}
.desc-toggle {
  margin-top: 5px; background: transparent; border: 1px dashed rgba(79, 140, 255, .5);
  color: var(--accent); font-size: 11px; padding: 2px 12px; border-radius: 999px;
  cursor: pointer; transition: border-color .15s, filter .15s;
}
.desc-toggle:hover { border-style: solid; filter: brightness(1.2); }
.tmeta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 5px; align-items: center; }
.mchip { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--card2); border: 1px solid var(--line); color: var(--muted); }
.mchip.overdue { color: var(--red); border-color: var(--red); }
.mchip.todaydue { color: var(--orange); border-color: var(--orange); }

.tside {
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  flex: none; justify-content: flex-end;
}
/* 按指派人筛选 */
.person-filter {
  appearance: none; -webkit-appearance: none;
  background: var(--card2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; font-size: 12px; padding: 5px 26px 5px 12px;
  cursor: pointer; outline: none; margin-left: 4px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6"><path d="M1 1l4 4 4-4" stroke="%238b93b0" fill="none" stroke-width="1.5"/></svg>');
  background-repeat: no-repeat; background-position: right 10px center;
  transition: border-color .15s;
}
.person-filter:hover { border-color: #5a6a9e; }
.person-filter option { background: var(--card); color: var(--text); }

/* 只读标签（状态 / 团队） */
.ro-tags { display: flex; align-items: center; gap: 6px; }
.ro-tag {
  font-size: 11px; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--card2); color: var(--muted);
}
.ro-tag.st-已完成 { color: var(--green); border-color: rgba(72, 187, 120, .5); background: rgba(72, 187, 120, .1); }
.ro-tag.st-进行中 { color: var(--orange); border-color: rgba(246, 173, 85, .5); background: rgba(246, 173, 85, .1); }
.ro-tag.st-未开始, .ro-tag.st-未启动 { color: var(--muted); }
.ro-tag.team-tag { color: var(--accent); border-color: rgba(79, 140, 255, .45); background: rgba(79, 140, 255, .1); }

/* 指派人下拉 */
.assign-select {
  appearance: none; -webkit-appearance: none;
  font-size: 12px; color: var(--text); cursor: pointer; outline: none;
  border: 1px solid rgba(79, 140, 255, .5); border-radius: 999px;
  padding: 4px 26px 4px 12px; min-width: 104px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6"><path d="M1 1l4 4 4-4" stroke="%238b93b0" fill="none" stroke-width="1.5"/></svg>'),
    linear-gradient(135deg, rgba(79, 140, 255, .18), rgba(155, 123, 255, .18));
  background-repeat: no-repeat; background-position: right 10px center, 0 0;
  transition: border-color .15s, filter .15s;
}
.assign-select:hover { filter: brightness(1.2); }
.assign-select option { background: var(--card); color: var(--text); }
.assign-select.assigned {
  color: var(--green); border-color: rgba(72, 187, 120, .6);
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6"><path d="M1 1l4 4 4-4" stroke="%2348bb78" fill="none" stroke-width="1.5"/></svg>'),
    linear-gradient(135deg, rgba(72, 187, 120, .16), rgba(79, 195, 178, .16));
}
.assign-line { font-size: 11px; color: var(--muted); }

/* ── 飞书资料页：项目切换器 ── */
.proj-switch { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.proj-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--card2); border: 1px solid var(--line); color: var(--muted);
  padding: 8px 20px; border-radius: 999px; font-size: 13px; cursor: pointer;
  transition: border-color .15s, color .15s, box-shadow .15s, background .15s;
}
.proj-btn b {
  font-size: 11px; background: rgba(79, 140, 255, .15); color: var(--accent);
  padding: 1px 8px; border-radius: 999px;
}
.proj-btn:hover { border-color: #5a6a9e; color: var(--text); }
.proj-btn.active {
  color: #fff; border-color: transparent;
  background: linear-gradient(90deg, #4f8cff, #9b7bff);
  box-shadow: 0 2px 14px rgba(79, 140, 255, .4);
}
.proj-btn.active b { background: rgba(255, 255, 255, .22); color: #fff; }
.pb-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ── 用户管理页 ─────────────────────── */
.users-main { max-width: 980px; margin: 0 auto; padding: 22px 28px 60px; }
.user-add-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
}
.user-add-card input {
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; color: var(--text); font-size: 13px; outline: none; min-width: 180px;
}
.user-add-card input::placeholder { color: var(--muted); }
.user-add-card input:focus { border-color: var(--accent); }
.btn-add {
  background: linear-gradient(90deg, #4f8cff, #9b7bff); color: #fff; border: none;
  border-radius: 10px; padding: 9px 22px; font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: 0 2px 10px rgba(79, 140, 255, .35); transition: filter .15s;
}
.btn-add:hover { filter: brightness(1.12); }
.team-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 14px; }
.chip {
  background: var(--card2); border: 1px solid var(--line); color: var(--muted);
  padding: 5px 14px; border-radius: 999px; font-size: 12px; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.chip b { color: var(--text); margin-left: 2px; }
.chip.active { color: #fff; border-color: var(--accent); background: rgba(79, 140, 255, .15); }
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.user-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  transition: border-color .15s;
}
.user-card:hover { border-color: #5a6a9e; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #4f8cff, #9b7bff);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 15px;
}
.u-info { min-width: 0; }
.u-name { font-weight: 600; font-size: 14px; }
.u-team { font-size: 11px; color: var(--accent); margin-top: 2px; }
.u-del {
  margin-left: auto; background: transparent; border: 1px solid var(--line);
  color: var(--muted); width: 24px; height: 24px; border-radius: 8px;
  font-size: 12px; cursor: pointer; line-height: 1; flex: none;
  transition: border-color .15s, color .15s;
}
.u-del:hover { border-color: var(--red); color: var(--red); }

/* ── 通用对话框（替代 alert/confirm） ── */
.dialog-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(8, 10, 22, .55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .18s;
}
.dialog-mask.show { opacity: 1; }
.dialog {
  width: min(92vw, 380px); background: var(--card);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 22px 24px 18px; box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  transform: translateY(12px) scale(.95); transition: transform .18s;
}
.dialog-mask.show .dialog { transform: none; }
.dialog-icon {
  width: 44px; height: 44px; border-radius: 50%; margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.dialog-icon.danger { background: rgba(248, 113, 113, .15); color: #f87171; }
.dialog-icon.warn { background: rgba(246, 173, 85, .15); color: var(--orange); }
.dialog-title { text-align: center; font-size: 15px; font-weight: 700; }
.dialog-msg { text-align: center; font-size: 12.5px; color: var(--muted); margin: 8px 0 18px; line-height: 1.6; }
.dialog-btns { display: flex; gap: 10px; }
.dialog-btns button {
  flex: 1; border-radius: 10px; padding: 9px 0; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--line);
  background: var(--card2); color: var(--text); transition: filter .15s;
}
.dialog-btns button:hover { filter: brightness(1.25); }
.dialog-btns .btn-danger {
  background: linear-gradient(90deg, #f56565, #fc8181); border: none; color: #fff;
  box-shadow: 0 2px 10px rgba(245, 101, 101, .35);
}
.dialog-btns .btn-primary {
  background: linear-gradient(90deg, #4f8cff, #9b7bff); border: none; color: #fff;
  box-shadow: 0 2px 10px rgba(79, 140, 255, .35);
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #233; color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 13px; border: 1px solid var(--line); z-index: 99; display: none;
}
.toast.error { border-color: var(--red); color: var(--red); }
.toast.show { display: block; animation: fadeout 2.4s forwards; }
@keyframes fadeout { 0% {opacity:1} 80% {opacity:1} 100% {opacity:0} }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.reauth {
  text-align: center; padding: 60px 20px; color: var(--text);
}
.reauth code { background: var(--card2); padding: 2px 8px; border-radius: 6px; color: var(--orange); }
