:root {
  --bg: #f4f6fa;
  --bg-grad: radial-gradient(1200px 600px at 12% -8%, #e8f0ff 0%, transparent 58%),
             radial-gradient(900px 500px at 92% 0%, #fdf3e6 0%, transparent 55%);
  --surface: #ffffff;
  --line: #e5e8ef;
  --line-soft: #eef1f6;
  --ink: #171c26;
  --ink-2: #4a5466;
  --ink-3: #808b9e;
  --accent: #2f6fed;
  --accent-soft: #eaf1ff;
  --amber: #c2740b;
  --amber-soft: #fdf4e5;
  --red: #c9372c;
  --red-soft: #fdeeec;
  --teal: #0f7d6c;
  --teal-soft: #e7f6f3;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(18, 26, 40, .04), 0 8px 24px -12px rgba(18, 26, 40, .12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

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

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

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

.brand-text { min-width: 0; }

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(145deg, #2f6fed, #1a4fd0);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.5px;
  box-shadow: 0 4px 12px -4px rgba(47, 111, 237, .55);
}

.brand-text h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text p {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: .3px;
}

.topnav { display: flex; gap: 2px; margin-left: 8px; }

.topnav a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 11px;
  border-radius: 8px;
  transition: .16s;
}

.topnav a:hover { background: var(--line-soft); color: var(--ink); }
.topnav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

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

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--line-soft);
  border-radius: 999px;
  padding: 5px 11px;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); }
.dot.busy { background: var(--amber); animation: pulse 1.1s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ---------- 布局 ---------- */
.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 24px 72px;
}

.hero {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 17px;
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: .4px;
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.kpi-value {
  font-size: 21px;
  font-weight: 660;
  letter-spacing: -.4px;
  line-height: 1.25;
}

.kpi-value.small { font-size: 15px; font-weight: 600; }
.kpi-sub { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* ---------- 区块卡片 ---------- */
.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.section-head h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 640;
  letter-spacing: .2px;
}

.section-head .count {
  font-size: 11.5px;
  color: var(--ink-3);
  background: var(--line-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

.section-head .hint {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--ink-3);
}

/* ---------- 表格 ---------- */
.table-scroll { overflow-x: auto; }

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.grid thead th {
  text-align: left;
  font-weight: 550;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: .3px;
  padding: 9px 14px;
  background: #fafbfd;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

table.grid thead th.r { text-align: right; }

table.grid tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover { background: #fafcff; }
table.grid td.r { text-align: right; }

.item-name {
  font-weight: 560;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.share { color: var(--ink-2); font-weight: 550; }
.muted { color: var(--ink-3); }

/* 未出进度 */
.gap-cell { min-width: 128px; }

.gap-top {
  display: flex;
  align-items: baseline;
  gap: 6px;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.gap-num { font-size: 14.5px; font-weight: 650; letter-spacing: -.2px; }
.gap-unit { font-size: 11px; color: var(--ink-3); }

.bar {
  height: 4px;
  border-radius: 999px;
  background: var(--line-soft);
  overflow: hidden;
  position: relative;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width .5s cubic-bezier(.2, .8, .2, 1);
}

.bar.warm > span { background: #e0a12a; }
.bar.hot > span { background: var(--red); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--line-soft);
  color: var(--ink-2);
  white-space: nowrap;
}

.tag.hot { background: var(--red-soft); color: var(--red); font-weight: 600; }
.tag.warm { background: var(--amber-soft); color: var(--amber); font-weight: 600; }
.tag.run { background: var(--teal-soft); color: var(--teal); font-weight: 600; }

.run-zero { color: var(--ink-3); }

.cell-sub { font-size: 11px; color: var(--ink-3); margin-top: 1px; }

/* ---------- 备注 ---------- */
.notes {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-top: 18px;
}

.notes h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 640;
  display: flex;
  align-items: center;
  gap: 8px;
}

.notes dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 26px;
}

.notes dt {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 2px;
}

.notes dd {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.65;
}

.disclaimer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.7;
}

.disclaimer strong { color: var(--amber); font-weight: 600; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-family: inherit;
  padding: 7px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: .16s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover { border-color: #cfd6e4; background: #fbfcfe; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 560;
  box-shadow: 0 4px 12px -5px rgba(47, 111, 237, .6);
}

.btn.primary:hover { background: #2a63d8; border-color: #2a63d8; }

/* ---------- 加载 / 空态 ---------- */
.loading {
  padding: 60px 0;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

.skeleton {
  height: 13px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f0f2f7 25%, #f7f8fb 37%, #f0f2f7 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
}

@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------- 明细页 ---------- */
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.input {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 9px;
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  transition: .16s;
  min-width: 170px;
}

.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.wide { min-width: 240px; }

.pager { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 12.5px; color: var(--ink-3); }

table.grid.compact tbody td { padding: 8px 10px; font-size: 12.5px; }
table.grid.compact thead th { padding: 8px 10px; }

.score-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--line-soft);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: .3px;
}

/* ---------- 管理页 ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 16px;
}

.panel h2 { margin: 0 0 4px; font-size: 14.5px; font-weight: 640; }
.panel .desc { margin: 0 0 16px; font-size: 12.5px; color: var(--ink-3); }

.form-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }

label.field { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 7px; }

.console {
  background: #131722;
  color: #cfd8e8;
  border-radius: 11px;
  padding: 14px 16px;
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.75;
  max-height: 340px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.console .ok { color: #5fd6a8; }
.console .err { color: #ff8a80; }

.banner {
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12.5px;
  margin-bottom: 14px;
  display: none;
}

.banner.show { display: block; }
.banner.ok { background: var(--teal-soft); color: var(--teal); }
.banner.err { background: var(--red-soft); color: var(--red); }

.runs-list { display: flex; flex-direction: column; gap: 8px; }

.run-item {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  font-size: 12.5px;
}

.run-item .meta { color: var(--ink-3); font-size: 11.5px; }

/* ---------- 口令弹层 / 轻提示（顶栏「更新数据」按钮用） ---------- */
.ovl {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(18, 26, 40, .38);
  opacity: 0;
  transition: opacity .18s;
}

.ovl.show { opacity: 1; }

.dialog {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 18px 48px -12px rgba(18, 26, 40, .38);
  padding: 20px;
  transform: translateY(8px) scale(.98);
  transition: transform .18s;
}

.ovl.show .dialog { transform: none; }

.dialog h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 650;
}

.dialog-desc {
  margin: 0 0 14px;
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.65;
}

.dialog .input { width: 100%; }

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.shake { animation: shake .38s; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-3px); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 70;
  transform: translate(-50%, 14px);
  max-width: min(560px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: 11px;
  background: #1d2532;
  color: #f3f6fb;
  font-size: 12.8px;
  line-height: 1.55;
  box-shadow: 0 12px 30px -10px rgba(18, 26, 40, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-type="err"] { background: #8f2f27; }

@media (max-width: 960px) {
  .hero { grid-template-columns: repeat(2, 1fr); }
  .notes dl { grid-template-columns: 1fr; }

  /* 手机上不再隐藏导航：整条折到第二行，做成两段式切换 */
  .topbar-inner { flex-wrap: wrap; row-gap: 9px; padding-bottom: 10px; }
  .brand { order: 1; flex: 1 1 auto; }
  .topbar-right { order: 2; flex: 0 0 auto; flex-wrap: nowrap; }
  .topnav {
    order: 3;
    flex: 0 0 100%;
    width: 100%;
    margin: 0;
    padding: 3px;
    gap: 4px;
    background: var(--line-soft);
    border-radius: 10px;
  }
  .topnav a {
    flex: 1 1 0;
    text-align: center;
    padding: 8px 6px;
    font-size: 13px;
    border-radius: 8px;
  }
  .topnav a.active { background: var(--surface); box-shadow: 0 1px 3px rgba(18, 26, 40, .1); }
  .brand-text p { display: none; }
  .topbar-right .pill { display: none; }

  /* 明细表在窄屏上横向滚动，别把「对阵」挤成一列竖排字 */
  table.grid.compact { min-width: 660px; }
  table.grid.compact tbody td { white-space: nowrap; }

  /* 首页统计表也保证横向滚动（表头 nowrap 已撑开，这里兜底） */
  table.grid { min-width: 620px; }

  /* 第一列吸附：横向滑动时「项目 / 业务日」跟着走，读者不会失去参照 */
  .table-scroll {
    position: relative;
    -webkit-overflow-scrolling: touch;
    /* 横向滑到头别把整页（微信里是返回手势）带出去 */
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
  }
  table.grid thead th:first-child,
  table.grid tbody td:first-child {
    position: sticky;
    left: 0;
    /* 必须不透明，否则右边的内容会从底下透出来 */
    background-color: var(--surface);
    /* border-collapse: collapse 下 sticky 单元格的 border 不绘制，
       分割线和投影都改成背景渐变：右边缘 6px 渐深 + 1px 实线 */
    background-image: linear-gradient(
      to right,
      rgba(27, 36, 52, 0) calc(100% - 7px),
      rgba(27, 36, 52, .2) calc(100% - 1px),
      #d3dae8 100%
    );
    background-repeat: no-repeat;
  }
  table.grid thead th:first-child {
    /* 表头要盖住吸附的数据列 */
    z-index: 5;
    /* 用 background-color，别用简写，否则会把上面的渐变分割线清掉 */
    background-color: #fafbfd;
  }
  table.grid tbody td:first-child { z-index: 2; }
  /* 行悬停时吸附列也要跟着变色，否则会留一块白（同样只用 background-color） */
  table.grid tbody tr:hover td:first-child { background-color: #fafcff; }
}

@media (max-width: 560px) {
  .wrap { padding: 18px 14px 60px; }
  .topbar-inner { padding: 10px 14px 9px; gap: 10px; }
  .hero { grid-template-columns: 1fr; }
  .kpi-value { font-size: 19px; }
  .brand-text h1 { font-size: 14px; }
  .brand-mark { width: 30px; height: 30px; font-size: 13px; }
  .topbar-right { gap: 8px; }
  .topbar-right .btn { padding: 6px 11px; font-size: 12.5px; }
  /* iOS 上 font-size < 16px 的输入框会触发自动放大 */
  .input { font-size: 16px; }
}
