:root {
  --bg: #faf9f5;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #656d76;
  --border: #e5e2dc;
  --accent: #1f2328;
  --red: #b42318;
  --red-bg: #fef3f2;
  --yellow: #b54708;
  --yellow-bg: #fffaeb;
  --green: #067647;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 96px; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--card);
}
.topbar-left { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; }
.agent-nav {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border);
}
.agent-nav-link {
  text-decoration: none; font-size: 13px; font-weight: 500;
  color: var(--muted); padding: 4px 10px; border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.agent-nav-link:hover { color: var(--text); }
.agent-nav-link.active {
  background: var(--card); color: var(--text); font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.top-actions { display: flex; gap: 8px; align-items: center; }
.quota-badge { font-size: 12px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; }
.quota-badge.exhausted { color: var(--red); border-color: var(--red); }
.privacy-notice { margin-top: 24px; font-size: 12px; padding: 8px 12px; border-top: 1px solid var(--border); }
.privacy-notice summary { cursor: pointer; }

.container { max-width: 1040px; margin: 20px auto; padding: 0 16px 48px; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 18px 20px; margin-bottom: 14px;
}
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 14px 0 8px; }

textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px; font-family: inherit; resize: vertical;
}
.input-collapsed { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.input-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip {
  background: #f3f1ec; border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.chip:hover { background: #e8e5de; }

.btn-primary {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 8px 18px; font-size: 14px; cursor: pointer;
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.link-btn { background: none; border: none; color: #0969da; cursor: pointer; padding: 0; font-size: 12px; text-decoration: underline; }

.muted { color: var(--muted); font-size: 12px; }
.hidden { display: none !important; }

.skeleton { margin-top: 12px; }
.skel-line {
  height: 14px; background: linear-gradient(90deg, #eee 25%, #f6f6f6 50%, #eee 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; margin-bottom: 8px;
}
.skel-line.short { width: 60%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.error-box {
  margin-top: 10px; padding: 10px 12px; background: var(--red-bg);
  color: var(--red); border: 1px solid #fecdca; border-radius: 8px; font-size: 13px;
}

/* 仪表盘 */
.dashboard-card {
  position: sticky; top: 0; z-index: 50;
  background: var(--card);
  transition: box-shadow 0.2s ease;
}
#result-section { overflow-anchor: none; }
.dashboard-card.stuck { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08); }
.dashboard-card.compact { padding: 8px 14px; }
.dashboard-card.compact .headline,
.dashboard-card.compact .gauge-zones,
.dashboard-card.compact .conf-note,
.dashboard-card.compact .marker-hint,
.dashboard-card.compact #score-range,
.dashboard-card.compact .synthesis-line,
.dashboard-card.compact #excluded-line { display: none; }
.dashboard-card.compact .score-label { font-size: 18px; }
.dashboard-card.compact .score-action { margin-top: 0; font-size: 13px; }
.dashboard-card.compact .dash-top { align-items: center; flex-wrap: nowrap; }
.dashboard-card.compact .gauge-wrap { margin: 8px 0 0; }
.dashboard-card.compact .gauge-track { height: 10px; }
.dashboard-card.compact .gauge-marker { height: 16px; top: -3px; }

.dash-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.score-label { font-size: 26px; font-weight: 700; line-height: 1.2; }
.score-action { font-size: 14px; font-weight: 600; margin-top: 4px; }
.dash-right { min-width: 220px; }
.conf-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.conf-track { flex: 1; height: 8px; background: #eee; border-radius: 999px; overflow: hidden; }
.conf-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.4s ease; }
.conf-note { font-size: 11px; color: var(--muted); margin-top: 4px; }

.gauge-wrap { margin: 18px 0 12px; }
.gauge-track {
  position: relative; width: 100%; height: 14px;
  background: #efede8; border-radius: 999px; overflow: visible;
}
.gauge-interval {
  position: absolute; top: 0; height: 100%;
  background: rgba(31, 35, 40, 0.22); border-radius: 999px;
  transition: left 0.4s ease, width 0.4s ease;
}
.gauge-marker {
  position: absolute; top: -3px; width: 6px; height: 20px;
  background: var(--accent); border-radius: 3px; transform: translateX(-50%);
  transition: left 0.4s ease;
}
.marker-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.gauge-zones {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-top: 6px;
}
.headline { white-space: pre-line; margin: 8px 0 0; font-size: 14px; }

/* 风险条 */
.risk-card summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.flags-list { list-style: none; padding: 0; margin: 10px 0 0; }
.flags-list li { padding: 7px 10px; border-radius: 6px; margin-bottom: 6px; font-size: 13px; }
.flag-red { background: var(--red-bg); color: var(--red); }
.flag-yellow { background: var(--yellow-bg); color: var(--yellow); }

/* 清单 */
.checklist-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.group-block { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.group-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.group-name { font-weight: 600; font-size: 14px; }
.group-gain { font-size: 12px; color: var(--green); }

.field-row {
  display: grid; grid-template-columns: 1.2fr 1.2fr auto; align-items: center;
  gap: 10px; padding: 7px 0; border-bottom: 1px dashed #f0eee9;
}
.field-row.skipped { opacity: 0.5; }
.field-label { font-size: 13px; }
.field-control { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.field-control input[type="text"], .field-control input[type="number"] {
  width: 130px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px;
}
.chip-opt {
  border: 1px solid var(--border); background: #fff; border-radius: 6px;
  padding: 3px 9px; font-size: 12px; cursor: pointer;
}
.chip-opt.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.field-actions { display: flex; align-items: center; gap: 8px; font-size: 12px; white-space: nowrap; }
.save-tick { color: var(--green); font-size: 12px; display: inline-block; width: 14px; text-align: center; }
.save-tick.hidden { display: inline-block !important; visibility: hidden; }
.clarify-banner { grid-column: 1 / -1; background: var(--yellow-bg); color: var(--yellow); padding: 4px 8px; border-radius: 6px; font-size: 12px; }

.append-box { display: flex; gap: 8px; margin-top: 14px; }
.append-box input { flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

/* 详细分析 */
.analysis-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stale-banner { font-size: 12px; color: var(--yellow); background: var(--yellow-bg); padding: 3px 8px; border-radius: 6px; }
.factors-table { display: grid; gap: 6px; }
.factor-row { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.advisor-item { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin-bottom: 6px; font-size: 13px; }
.simple-list { padding-left: 18px; margin: 0 0 10px; font-size: 13px; }
.vd-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; font-size: 13px; }
.vd-col { border: 1px solid var(--border); border-radius: 8px; padding: 10px; }

.disclaimer { font-size: 12px; color: var(--muted); text-align: center; margin-top: 16px; }

.drawer {
  position: fixed; top: 0; right: 0; width: 320px; height: 100%;
  background: var(--card); border-left: 1px solid var(--border);
  padding: 16px; overflow-y: auto; z-index: 100;
}
.drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.history-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.history-title { font-weight: 600; font-size: 14px; cursor: pointer; }
.history-meta { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; margin-top: 4px; }

.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-content { width: 420px; max-width: 92vw; }
.modal-content label { display: block; font-size: 13px; margin-bottom: 10px; }
.modal-content input { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; margin-top: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

.row-error { grid-column: 1 / -1; color: var(--red); font-size: 12px; }
.synthesis-line { margin: 6px 0 0; font-size: 13px; font-weight: 600; cursor: pointer; }
.group-block.highlight { background: #fffaeb; transition: background 0.3s; }
.group-excluded { color: var(--muted); font-size: 13px; padding: 6px 0; }

@media (max-width: 640px) {
  .dash-right { min-width: 0; flex: 1; }
  .field-row { grid-template-columns: 1fr; }
  .vd-grid { grid-template-columns: 1fr; }
}

/* === 智囊团展示 (v2.4.6) === */
.advisor-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--primary, #2563eb);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0;
}

.advisor-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #9ca3af;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.advisors-modal-content {
  max-width: 680px;
  width: 92vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.advisors-modal-body {
  overflow-y: auto;
  padding-right: 4px;
  margin: 10px 0;
}
.advisors-modal-sec {
  margin-bottom: 14px;
}
.advisors-modal-sec-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted, #4b5563);
  margin-bottom: 8px;
}
.advisors-modal-item {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fafafa;
}
.advisors-modal-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.advisors-modal-item-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.advisors-modal-code {
  font-weight: 600;
  font-size: 14px;
}
.advisors-modal-group,
.advisors-modal-tag {
  font-size: 12px;
  color: var(--muted, #4b5563);
}
.advisors-modal-note {
  font-size: 12px;
  color: #b45309;
  margin-bottom: 4px;
}
.advisors-modal-row {
  font-size: 13px;
  margin: 3px 0;
}
.advisors-modal-rule {
  font-size: 12px;
  color: var(--muted, #4b5563);
  margin-top: 4px;
}
.advisors-modal-foot {
  font-size: 12px;
  color: var(--muted, #4b5563);
  border-top: 1px solid #e5e7eb;
  padding-top: 8px;
}
.advisors-modal-empty {
  padding: 16px 0;
  color: var(--muted, #4b5563);
}

@media (max-width: 640px) {
  .advisors-modal-content {
    max-height: 90vh;
  }
  .rp-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .rp-table th,
  .rp-table td {
    white-space: nowrap;
  }
  .rp-badge {
    white-space: nowrap;
    display: inline-block;
  }
}
