:root {
  --brand: #0a4d8c;
  --brand-2: #1272c4;
  --brand-dark: #083a6b;
  --bg: #f1f4f8;
  --card: #ffffff;
  --text: #1a2431;
  --text-2: #5a6b7f;
  --text-3: #93a1b3;
  --line: #e6ebf2;
  --red: #e34d59;
  --orange: #ed7b2f;
  --green: #00a870;
  --blue: #1272c4;
  --purple: #7a5af8;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 40, 70, .08), 0 1px 2px rgba(16, 40, 70, .04);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

#app { max-width: 720px; margin: 0 auto; min-height: 100vh; background: var(--bg); }

.boot-loading { padding: 120px 20px; text-align: center; color: var(--text-3); }
.boot-spinner {
  width: 32px; height: 32px; margin: 0 auto 14px;
  border: 3px solid #dbe4ee; border-top-color: var(--brand);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 顶部栏 ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff; padding: 12px 16px calc(12px);
  display: flex; align-items: center; gap: 10px;
}
.appbar .title { font-size: 17px; font-weight: 600; flex: 1; }
.appbar .sub { font-size: 11px; opacity: .8; font-weight: 400; margin-top: 1px; }
.appbar .icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: rgba(255,255,255,.16); color: #fff; font-size: 15px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.appbar-back {
  width: 28px; height: 28px; border-radius: 8px; border: none; background: rgba(255,255,255,.16);
  color: #fff; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* ---------- 容器 ---------- */
.page { padding: 12px 12px 90px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px;
}
.card-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-hd h3 { margin: 0; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.card-hd .more { font-size: 12px; color: var(--text-3); }
.card-hd .more:active { color: var(--brand); }
.sec-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 16px 4px 8px; }

/* ---------- 登录 ---------- */
.login-wrap { padding: 40px 20px; }
.login-hero { text-align: center; margin-bottom: 24px; }
.login-hero .logo {
  width: 62px; height: 62px; margin: 0 auto 12px; border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-size: 28px; display: flex; align-items: center; justify-content: center;
}
.login-hero h1 { font-size: 19px; margin: 0 0 6px; }
.login-hero p { color: var(--text-2); font-size: 12px; margin: 0; }
.user-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.user-pick button {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px;
  text-align: left; cursor: pointer; font-size: 13px; color: var(--text);
}
.user-pick button:active { background: #eef4fb; border-color: var(--brand-2); }
.user-pick .n { font-weight: 600; }
.user-pick .t { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ---------- 指标 ---------- */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.metric {
  background: #fff; border-radius: 10px; padding: 10px 6px; text-align: center; box-shadow: var(--shadow);
}
.metric .v { font-size: 19px; font-weight: 700; line-height: 1.2; }
.metric .l { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.metric.red .v { color: var(--red); }
.metric.orange .v { color: var(--orange); }
.metric.green .v { color: var(--green); }
.metric.blue .v { color: var(--brand-2); }

/* ---------- 项目卡 ---------- */
.proj {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 10px; cursor: pointer; border-left: 4px solid var(--green);
}
.proj:active { background: #fafbfd; }
.proj.lv-red { border-left-color: var(--red); }
.proj.lv-yellow { border-left-color: var(--orange); }
.proj.lv-green { border-left-color: var(--green); }
.proj-hd { display: flex; align-items: center; justify-content: space-between; }
.proj-code { font-size: 16px; font-weight: 700; font-family: "SF Mono", Consolas, monospace; }
.proj-name { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 600; white-space: nowrap;
}
.badge.red { background: #fdeaec; color: var(--red); }
.badge.yellow { background: #fdf1e6; color: var(--orange); }
.badge.green { background: #e3f7f0; color: var(--green); }
.badge.blue { background: #e8f1fb; color: var(--brand-2); }
.badge.gray { background: #eef1f5; color: var(--text-2); }
.badge.purple { background: #f0ecfe; color: var(--purple); }

.bar { height: 6px; background: #edf1f6; border-radius: 4px; overflow: hidden; margin: 10px 0 6px; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--brand-2); }
.bar.red > i { background: var(--red); }
.bar.orange > i { background: var(--orange); }
.bar.green > i { background: var(--green); }
.proj-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); }
.reasons { margin-top: 8px; font-size: 11px; color: var(--text-2); }
.reasons span { display: inline-block; background: #f6f8fb; border-radius: 4px; padding: 2px 6px; margin: 2px 4px 0 0; }

/* ---------- 列表项 ---------- */
.item {
  display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: none; }
.item:active { background: #fafbfd; }
.item-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.item-body { flex: 1; min-width: 0; }
.item-t { font-size: 13px; font-weight: 500; }
.item-m { font-size: 11px; color: var(--text-3); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 8px; }
.item-r { text-align: right; flex: none; font-size: 11px; color: var(--text-3); }

/* ---------- 标签页 ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none; border: 1px solid var(--line); background: #fff; color: var(--text-2);
  padding: 6px 14px; border-radius: 20px; font-size: 12px; cursor: pointer;
}
.tabs button.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* ---------- 里程碑时间轴 ---------- */
.ms { position: relative; padding-left: 18px; }
.ms-item { position: relative; padding: 8px 0 8px 12px; border-left: 2px solid var(--line); }
.ms-item:last-child { border-left-color: transparent; }
.ms-item .dot {
  position: absolute; left: -7px; top: 12px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2px solid var(--line);
}
.ms-item.done .dot { background: var(--green); border-color: var(--green); }
.ms-item.doing .dot { background: var(--orange); border-color: var(--orange); }
.ms-item .n { font-size: 13px; font-weight: 500; }
.ms-item.done .n { color: var(--text-2); }
.ms-item .d { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ---------- WBS / 树 ---------- */
.wbs-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.wbs-row:last-child { border-bottom: none; }
.wbs-row .code { font-size: 11px; color: var(--text-3); width: 34px; flex: none; font-family: Consolas, monospace; }
.wbs-row .nm { flex: 1; font-size: 13px; min-width: 0; }
.wbs-row .pg { width: 92px; flex: none; display: flex; align-items: center; gap: 6px; }
.wbs-row .pg .bar { margin: 0; flex: 1; }
.wbs-row .pg .t { font-size: 11px; color: var(--text-2); width: 34px; text-align: right; }

/* ---------- 甘特（flex 布局，横向滚动） ---------- */
.gantt-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.gantt-wrap::-webkit-scrollbar { height: 4px; }
.gantt-wrap::-webkit-scrollbar-thumb { background: #d8e0ea; border-radius: 2px; }
.gantt-inner { font-size: 11px; }
.ghead { display: flex; align-items: flex-end; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.ghead .gname { color: var(--text-3); font-size: 10px; }
.gcol-head { flex: none; text-align: center; color: var(--text-3); font-size: 9px; line-height: 1.3; }
.grow { display: flex; align-items: center; height: 26px; }
.gname {
  width: 120px; flex: none; padding-right: 8px; font-size: 11px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gtrack { position: relative; height: 22px; flex: none; display: flex; align-items: stretch; }
.gtrack::before {
  content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(to right, #f4f7fa 0 1px, transparent 1px 100%);
  background-size: 26px 100%;
}
.gbar {
  position: absolute; top: 4px; height: 14px; border-radius: 3px;
  background: #c9dcee; overflow: hidden; min-width: 8px;
}
.gbar > i { display: block; height: 100%; background: var(--brand-2); }
.gbar.done > i { background: var(--green); }
.gbar.blocked > i { background: var(--red); }
.gbar.overdue > i { background: var(--orange); }
.gbar .gtxt {
  position: absolute; right: 2px; top: 0; font-size: 8px; line-height: 14px; color: #fff;
  text-shadow: 0 0 2px rgba(0,0,0,.35);
}
.gtoday { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); opacity: .7; z-index: 2; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 5px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px;
  font-size: 14px; color: var(--text); background: #fff; outline: none; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-2); }
.field textarea { min-height: 62px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.range { display: flex; align-items: center; gap: 10px; }
.range input[type=range] { flex: 1; accent-color: var(--brand); }
.range .val { width: 46px; text-align: right; font-weight: 600; color: var(--brand); }

.btn {
  width: 100%; border: none; border-radius: 10px; padding: 12px; font-size: 15px; font-weight: 600;
  background: var(--brand); color: #fff; cursor: pointer; font-family: inherit;
}
.btn:active { background: var(--brand-dark); }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.gray { background: #eef1f5; color: var(--text-2); }
.btn.sm { padding: 8px 12px; font-size: 13px; width: auto; border-radius: 8px; }
.btn-row { display: flex; gap: 10px; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: #fff; border-top: 1px solid var(--line); display: flex;
  padding-bottom: var(--safe-bottom); max-width: 720px; margin: 0 auto;
}
.tabbar button {
  flex: 1; border: none; background: none; padding: 7px 2px 6px; cursor: pointer;
  color: var(--text-3); font-size: 10px; font-family: inherit;
}
.tabbar button .ic { font-size: 19px; display: block; line-height: 1.2; }
.tabbar button.on { color: var(--brand); font-weight: 600; }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(10, 25, 45, .45); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: #fff; width: 100%; max-width: 720px; border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(20px + var(--safe-bottom)); max-height: 86vh; overflow-y: auto;
  animation: up .22s ease;
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
.sheet-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-hd h3 { margin: 0; font-size: 16px; }
.sheet-hd .x { border: none; background: #f1f4f8; width: 28px; height: 28px; border-radius: 50%; font-size: 15px; color: var(--text-2); cursor: pointer; }

/* ---------- 杂项 ---------- */
.empty { text-align: center; padding: 34px 10px; color: var(--text-3); font-size: 13px; }
.hint { font-size: 11px; color: var(--text-3); line-height: 1.6; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; font-size: 13px; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-2); }
.dot-i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.fab {
  position: fixed; right: 16px; bottom: calc(66px + var(--safe-bottom)); z-index: 35;
  width: 50px; height: 50px; border-radius: 25px; border: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  font-size: 26px; line-height: 1; box-shadow: 0 4px 14px rgba(10, 77, 140, .35); cursor: pointer;
}
.toast {
  position: fixed; left: 50%; top: 42%; transform: translateX(-50%);
  background: rgba(20, 34, 52, .92); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; z-index: 99; max-width: 80%; text-align: center;
}
