/* 质环 QualityLoop — 设计令牌与组件类（浅色主题，仅系统字体） */

:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --line: #e8e8e4;
  --text: #1a1a1a;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --brand: #4f46e5;
  --brand-soft: #eef2ff;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info: #2563eb;
  --info-bg: #eff6ff;
  --ai-grad: linear-gradient(135deg, #6366f1, #06b6d4);
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-hover: 0 4px 10px rgba(16, 24, 40, 0.08), 0 2px 4px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.tnum { font-variant-numeric: tabular-nums; }

a { color: inherit; text-decoration: none; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* ---------- 布局骨架 ---------- */

.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

/* Bind padding to the page slot id so it survives in-app main swaps
   (the .app-main class is added by nav.js and can be missing after a swap). */
#app-main,
.app-main {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

#app-main.app-main--narrow,
.app-main--narrow { max-width: 920px; }

/* ---------- 侧边导航 ---------- */

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 14px;
}

.nav-logo-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  flex-shrink: 0;
  object-fit: cover;
}

.nav-logo-name { font-weight: 650; font-size: 16px; letter-spacing: 0.01em; }
.nav-logo-sub { font-size: 11px; color: var(--text-3); line-height: 1.2; }

.nav-list { padding: 6px 12px; flex: 1; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 150ms ease-out, color 150ms ease-out;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: #f3f4f2; color: var(--text); }
.nav-item.is-active { background: var(--brand-soft); color: var(--brand); }

.nav-section { padding: 14px 24px 4px; font-size: 11px; color: var(--text-3); letter-spacing: 0.06em; }

.nav-user {
  border-top: 1px solid var(--line);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- 通用组件 ---------- */

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

.card-hover { transition: transform 150ms ease-out, box-shadow 150ms ease-out; }
.card-hover:hover { transform: translateY(-1px); box-shadow: var(--shadow-hover); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
}

.avatar {
  width: 26px; height: 26px;
  border-radius: 999px;
  display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  object-fit: cover;
  background: #e8e8e4;
}

img.avatar {
  padding: 0;
  color: transparent;
}

.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  transition: background 150ms ease-out;
}
.btn-primary:hover { background: #4338ca; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 150ms ease-out, border-color 150ms ease-out;
}
.btn-ghost:hover { background: #f6f6f4; border-color: #d9d9d4; }

.input {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  width: 100%;
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }

/* ---------- AI 卡片 ---------- */

.ai-card {
  position: relative;
  border-radius: 16px;
  background: linear-gradient(var(--card), var(--card)) padding-box,
    var(--ai-grad) border-box;
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
}

.ai-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600;
  background: var(--ai-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- 阶段进度 stepper ---------- */

.stepper { display: flex; flex-direction: column; gap: 0; }

.step { display: flex; gap: 12px; }

.step-rail { display: flex; flex-direction: column; align-items: center; width: 22px; flex-shrink: 0; }

.step-dot {
  width: 22px; height: 22px;
  border-radius: 999px;
  display: grid; place-items: center;
  font-size: 11px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--text-3);
  flex-shrink: 0;
}

.step-line { width: 2px; flex: 1; min-height: 14px; background: var(--line); }

.step.is-done .step-dot { border-color: var(--ok); background: var(--ok); color: #fff; }
.step.is-done .step-line { background: var(--ok); }
.step.is-current .step-dot { border-color: var(--brand); background: var(--brand); color: #fff; box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15); }

.step-label { padding-bottom: 16px; font-size: 13px; color: var(--text-2); padding-top: 1px; }
.step.is-current .step-label { color: var(--brand); font-weight: 600; }
.step.is-done .step-label { color: var(--text); }

/* ---------- 时间线 ---------- */

.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; width: 12px; flex-shrink: 0; padding-top: 5px; }
.tl-dot { width: 9px; height: 9px; border-radius: 999px; background: var(--text-3); flex-shrink: 0; }
.tl-line { width: 2px; flex: 1; background: var(--line); margin-top: 3px; }
.tl-body { padding-bottom: 18px; min-width: 0; }

/* ---------- 表格 ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-3);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid #f0f0ed; vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: background 120ms ease-out; }
.table tbody tr:hover { background: #fafaf8; }
.table tbody tr:last-child td { border-bottom: none; }

/* ---------- 筛选 chips ---------- */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: all 150ms ease-out;
}
.chip:hover { border-color: #d0d0ca; }
.chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- KPI ---------- */

.kpi-num { font-size: 36px; font-weight: 650; line-height: 1.1; letter-spacing: -0.01em; }

/* ---------- 遏制卡片 ---------- */

.contain-list { display: flex; flex-direction: column; gap: 10px; }

.contain-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: #fbfbf9;
  transition: border-color 150ms ease-out, background 150ms ease-out;
}
.contain-card.is-done { background: var(--ok-bg); border-color: #bbf7d0; }

.contain-check {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12.5px; color: var(--text-2); cursor: pointer;
  user-select: none;
}
.contain-check input { margin-top: 2px; accent-color: var(--brand); cursor: pointer; }
.contain-check.is-checked { color: var(--text); }

/* ---------- Toast ---------- */

.toast-host {
  position: fixed; right: 20px; bottom: 20px; z-index: 80;
  display: flex; flex-direction: column; gap: 8px; max-width: 360px;
}
.toast {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 12px 14px; border-radius: 12px;
  background: #1a1a1a; color: #fff; font-size: 13px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.18);
  opacity: 0; transform: translateY(8px);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
}
.toast.is-in { opacity: 1; transform: translateY(0); }
.toast a { color: #a5b4fc; font-weight: 600; white-space: nowrap; }

.kb-new { box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.25); }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(16, 24, 40, 0.36);
  display: none; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-overlay.is-open { display: flex; }

.modal-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 48px rgba(16, 24, 40, 0.18);
  padding: 20px 22px;
}
.modal-card-lg { width: min(640px, 100%); max-height: min(80vh, 720px); overflow: auto; }

.drawer-root {
  position: fixed; inset: 0; z-index: 85;
  pointer-events: none;
}
.drawer-root.is-open { pointer-events: auto; }
.drawer-root .drawer-overlay {
  position: absolute; inset: 0;
  background: rgba(16, 24, 40, 0.28);
  opacity: 0; transition: opacity 180ms ease-out;
}
.drawer-root.is-open .drawer-overlay { opacity: 1; }
.drawer-root .drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(420px, 100%);
  background: var(--card);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 32px rgba(16, 24, 40, 0.1);
  transform: translateX(100%);
  transition: transform 200ms ease-out;
  display: flex; flex-direction: column;
  padding: 20px 22px;
}
.drawer-root.is-open .drawer-panel { transform: translateX(0); }

/* ---------- 响应式 ---------- */

@media (max-width: 1023px) {
  .app-sidebar { width: 64px; }
  .nav-logo-name, .nav-logo-sub, .nav-item span, .nav-section, .nav-user div { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-logo { justify-content: center; padding: 16px 8px; }
  .nav-user { justify-content: center; }
  #app-main,
  .app-main { padding: 16px; }
}

@media print {
  .app-sidebar, .app-topbar { display: none; }
}
