/* ============ 基础 ============ */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e3e6ea;
  --border-strong: #d0d5db;
  --text: #1f2328;
  --text-2: #5c6470;
  --text-3: #8b939e;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff4ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --ok: #16a34a;
  --ok-soft: #f0fdf4;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

/* ============ 顶部栏 ============ */
.header {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.logo-icon { color: var(--primary); font-size: 20px; }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }

/* 搜索框 */
.search-box { position: relative; flex: 1; max-width: 380px; }
.search-box input {
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: all .15s;
}
.search-box input:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.search-results {
  position: absolute;
  top: 40px; left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 380px;
  overflow-y: auto;
  z-index: 60;
}
.search-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--primary-soft); }
.search-item-title { font-weight: 600; font-size: 13px; }
.search-item-preview {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-empty { padding: 16px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ============ 按钮 ============ */
.btn {
  height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.icon-btn {
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 14px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ============ 布局 ============ */
.layout { display: flex; height: calc(100vh - 56px); }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 0;
}
.sidebar-section { margin-bottom: 8px; }
.sidebar-title {
  padding: 0 16px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.tree-group { margin-bottom: 2px; }
.tree-group-title {
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.tree-group-title:hover { color: var(--text); }
.tree-item {
  display: block;
  padding: 5px 16px 5px 32px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  border-left: 2px solid transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-item:hover { background: var(--surface-2); color: var(--text); }
.tree-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}
.tree-empty { padding: 8px 16px; font-size: 12px; color: var(--text-3); }

.content { flex: 1; overflow-y: auto; padding: 28px 32px 80px; }
.content-inner { max-width: 960px; margin: 0 auto; }

/* ============ 通用头部 ============ */
.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.page-head h1 { font-size: 24px; font-weight: 700; line-height: 1.3; }
.page-head-actions { margin-left: auto; display: flex; gap: 6px; flex-shrink: 0; }
.page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-3);
}

/* ============ 卡片 ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  transition: box-shadow .15s, border-color .15s;
}
.card:hover { box-shadow: var(--shadow); }
.card-head { display: flex; align-items: flex-start; gap: 12px; }
.card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.card-title a { color: inherit; text-decoration: none; }
.card-title a:hover { color: var(--primary); }
.card-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.card-desc {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-actions { margin-left: auto; display: flex; gap: 6px; flex-shrink: 0; }

/* 统计卡片 */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* 严重级别配色 */
.sev-critical { color: #b91c1c; }
.sev-high { color: #ea580c; }
.sev-medium { color: #ca8a04; }
.sev-low { color: #16a34a; }
.sev-info { color: #2563eb; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}
.badge-critical { background: #fee2e2; color: #b91c1c; }
.badge-high { background: #ffedd5; color: #c2410c; }
.badge-medium { background: #fef3c7; color: #a16207; }
.badge-low { background: #dcfce7; color: #15803d; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f1f3f5; color: #5c6470; }

.cvss {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  min-width: 44px;
}

/* 分页 */
.pager {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  margin: 24px 0 8px;
  flex-wrap: wrap;
}
.pager-dots { color: var(--text-3); padding: 0 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface); border-color: transparent; }

/* 折叠详情 */
details.detail { margin-top: 10px; }
details.detail summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  padding: 4px 0;
  user-select: none;
}
details.detail summary:hover { text-decoration: underline; }

/* ============ 筛选栏 ============ */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  align-items: center;
}
.filter-chip {
  padding: 4px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.filter-input {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  min-width: 180px;
}
.filter-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* ============ 空状态 ============ */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.empty-icon { font-size: 40px; margin-bottom: 8px; opacity: .5; }
.empty-title { font-size: 15px; color: var(--text-2); margin-bottom: 16px; }

/* ============ Markdown 渲染 ============ */
.markdown { font-size: 14.5px; line-height: 1.75; color: var(--text); }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: 1.6em 0 .7em; line-height: 1.35; font-weight: 700; }
.markdown h1 { font-size: 26px; padding-bottom: .3em; border-bottom: 1px solid var(--border); margin-top: 0; }
.markdown h2 { font-size: 21px; padding-bottom: .25em; border-bottom: 1px solid var(--border); }
.markdown h3 { font-size: 17px; }
.markdown h4 { font-size: 15px; }
.markdown p { margin: .8em 0; }
.markdown ul, .markdown ol { margin: .8em 0; padding-left: 1.6em; }
.markdown li { margin: .3em 0; }
.markdown a { color: var(--primary); text-decoration: none; }
.markdown a:hover { text-decoration: underline; }
.markdown strong { font-weight: 700; }
.markdown blockquote {
  margin: 1em 0;
  padding: 10px 16px;
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  border-radius: 0 6px 6px 0;
  color: var(--text-2);
}
.markdown code {
  background: #f1f3f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: #b91c1c;
}
.markdown pre {
  background: #1f2328;
  color: #e6edf3;
  padding: 14px 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1em 0;
  line-height: 1.55;
}
.markdown pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 12.5px;
}
.markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 13.5px;
  display: block;
  overflow-x: auto;
}
.markdown th, .markdown td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.markdown th { background: var(--surface-2); font-weight: 600; }
.markdown tbody tr:nth-child(even) { background: var(--surface-2); }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 1.6em 0; }
.markdown img { max-width: 100%; border-radius: 6px; }

/* ============ 模态框 ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  z-index: 100;
}
.modal-box {
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
}
.modal-lg { max-width: 820px; }
.modal-head {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 700;
}
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 10px 10px;
}

/* 表单 */
.field { margin-bottom: 14px; flex: 1; min-width: 0; }
.field-sm { max-width: 130px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: all .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.field textarea { resize: vertical; line-height: 1.6; }
.field textarea.mono, .mono { font-family: var(--mono); font-size: 12.5px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }

.editor-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.tabs { display: flex; gap: 2px; }
.tab {
  padding: 3px 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-2);
}
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

.md-preview {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  min-height: 300px;
  max-height: 460px;
  overflow-y: auto;
  background: var(--surface-2);
}

/* ============ 版本列表 ============ */
.version-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.version-item:last-child { border-bottom: none; }
.version-info { flex: 1; }
.version-time { font-size: 13px; font-weight: 600; }
.version-meta { font-size: 12px; color: var(--text-3); }

/* ============ 检查清单 ============ */
.check-group { margin-bottom: 20px; }
.check-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}
.check-item:last-child { border-bottom: none; }
.check-item:hover { background: var(--surface-2); }
.check-item input { margin-top: 4px; cursor: pointer; width: 15px; height: 15px; accent-color: var(--primary); }
.check-item.done span { text-decoration: line-through; color: var(--text-3); }
.check-progress { font-size: 12px; color: var(--text-3); font-weight: 500; }

/* ============ 提示条 ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2328;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

/* ============ 杂项 ============ */
.hidden { display: none !important; }
.mono-snippet {
  background: #1f2328;
  color: #e6edf3;
  padding: 10px 12px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  margin: 20px 0 10px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
