/**
 * risk-page.css — 风险推演页面样式
 * 比赛展示级 · 冷灰白基调 · 克制专业
 * 所有样式限定在 #page-risk 内
 * ============================================================================
 */

/* ==========================================================================
   Layout
   ========================================================================== */

#page-risk {
  background: var(--bg-page);
}

#page-risk .risk-layout {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ==========================================================================
   Sidebar (300px)
   ========================================================================== */

.risk-sidebar {
  width: 300px;
  min-width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #F4F6F9;
  border-right: 1px solid var(--border-subtle);
  overflow: hidden;
}

.risk-sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 18px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 0.5px solid var(--border-subtle);
  flex-shrink: 0;
}

.risk-sidebar-header svg {
  color: #D97706;
  flex-shrink: 0;
}

/* ==========================================================================
   Source Task Display (from TaskContext)
   ========================================================================== */

.risk-source-task {
  padding: 10px 16px 8px;
  border-bottom: 0.5px solid var(--border-subtle);
  flex-shrink: 0;
  background: rgba(59, 130, 246, 0.03);
}

.risk-source-task-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  color: var(--brand-blue);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
}

.risk-source-task-label svg {
  color: var(--brand-blue);
}

.risk-source-task-id {
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 10px;
  color: var(--brand-blue);
  font-weight: 700;
  margin-bottom: 3px;
  letter-spacing: 0.02em;
}

.risk-source-task-query {
  font-size: 11px;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.risk-source-task-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 10px;
}

/* 真实任务也使用同一套推演工作台。来源任务压缩成基准卡，避免把
   左侧空间全部占满，让场景、参数和历史始终可见。 */
#page-risk.risk-real-workbench .risk-source-task {
  max-height: none;
  overflow: hidden;
  padding-top: 8px;
  padding-bottom: 8px;
}

#page-risk.risk-real-workbench .risk-source-task-query {
  -webkit-line-clamp: 2;
  margin-bottom: 4px;
}

#page-risk.risk-real-workbench .risk-recommendation {
  padding-top: 6px;
  padding-bottom: 6px;
}

#page-risk.risk-real-workbench .risk-config-section {
  padding-top: 10px;
  padding-bottom: 10px;
}

.risk-source-stat {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  background: rgba(59, 130, 246, 0.06);
  border-radius: 4px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.risk-source-period-stat {
  align-items: flex-start;
  white-space: normal;
}

.risk-source-period-lines {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.35;
}

.risk-source-period-more {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 9px;
}

.risk-source-stat.val-warn {
  color: #D97706;
  background: rgba(245, 158, 11, 0.08);
}

/* ==========================================================================
   Agent Recommendation
   ========================================================================== */

/* Config sections */
.risk-config-section {
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--border-subtle);
  flex-shrink: 0;
}

.risk-config-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

/* ---- Scenario list ---- */
.risk-scenario-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.risk-scenario-select {
  width: 100%;
  min-height: 34px;
  padding: 7px 30px 7px 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-primary);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.risk-scenario-select:focus {
  outline: 2px solid rgba(217, 119, 6, 0.22);
  border-color: #D97706;
}

.risk-scenario-description {
  padding: 5px 2px 0;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.risk-scenario-recommendation {
  padding: 6px 8px;
  border-left: 2px solid #10B981;
  border-radius: 4px;
  background: rgba(16,185,129,.07);
  color: #047857;
  font-size: 10px;
  line-height: 1.35;
}

.risk-scenario-recommendation-title {
  display: flex;
  align-items: baseline;
  gap: 2px;
  min-width: 0;
  line-height: 1.4;
}

.risk-scenario-recommendation-title span {
  flex-shrink: 0;
  font-weight: 700;
}

.risk-scenario-recommendation-title strong {
  min-width: 0;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.risk-scenario-recommendation-reason {
  margin-top: 2px;
  overflow: hidden;
  color: #64748B;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.risk-scenario-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  text-align: left;
}

.risk-scenario-btn:hover {
  border-color: #D97706;
  color: var(--text-primary);
}

.risk-scenario-btn.active {
  border-color: #D97706;
  background: rgba(217, 119, 6, 0.04);
  color: #92400E;
  font-weight: 600;
}

.risk-scenario-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---- Parameter sliders ---- */
.risk-params {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.risk-param-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.risk-param-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.risk-param-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.risk-param-value {
  font-size: 10.5px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.risk-param-value.deviation {
  color: #D97706;
}

.risk-param-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.risk-param-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #D97706;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: transform 0.15s ease;
}

.risk-param-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.risk-param-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #D97706;
  cursor: pointer;
}

/* ---- Action ---- */
.risk-action-area {
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--border-subtle);
  flex-shrink: 0;
}

.risk-btn-start {
  width: 100%;
  padding: 10px 14px;
  background: #D97706;
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.risk-btn-start:hover {
  background: #B45309;
  box-shadow: 0 2px 10px rgba(217, 119, 6, 0.3);
}

.risk-btn-start:active {
  transform: scale(0.98);
}

.risk-btn-start:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

/* ---- History ---- */
.risk-history-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.risk-history-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.risk-history-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--border-default);
}

.risk-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px;
}

.risk-history-list::-webkit-scrollbar {
  width: 3px;
}
.risk-history-list::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 2px;
}

.risk-history-item {
  padding: 10px 12px;
  margin-bottom: 6px;
  background: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.risk-history-item:hover {
  border-color: var(--border-default);
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}

.risk-history-item.active {
  border-color: #D97706;
  background: rgba(217, 119, 6, 0.03);
}

.risk-history-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.risk-history-scenario {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.risk-history-badge {
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.risk-history-badge.warning { background: rgba(245,158,11,0.1); color: #D97706; }
.risk-history-badge.normal  { background: rgba(16,185,129,0.1); color: #059669; }
.risk-history-badge.critical { background: rgba(239,68,68,0.1); color: #DC2626; }

.risk-history-time {
  font-size: 10.5px;
  color: var(--text-muted);
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */

.risk-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px 20px;
  min-width: 0;
  gap: 14px;
}

.risk-main::-webkit-scrollbar {
  width: 5px;
}
.risk-main::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 3px;
}
.risk-main::-webkit-scrollbar-track {
  background: transparent;
}

/* ==========================================================================
   Section Header
   ========================================================================== */

.risk-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.risk-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.risk-section-title svg {
  color: #D97706;
}

/* ==========================================================================
   Pipeline
   ========================================================================== */

.risk-pipeline-section {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 14px 18px;
  flex-shrink: 0;
}

.risk-pipeline-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.risk-progress-track {
  width: 120px;
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
}

.risk-progress-fill {
  height: 100%;
  width: 100%;
  background: #D97706;
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.4s ease;
}

.risk-progress-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 48px;
}

.risk-pipeline-steps {
  display: flex;
  gap: 1px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.risk-pipeline-steps::-webkit-scrollbar {
  height: 3px;
}
.risk-pipeline-steps::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 2px;
}

.risk-step-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: all 0.25s ease;
  font-size: 11px;
}

.risk-step-item.waiting   { color: var(--text-muted); }
.risk-step-item.running   { background: #D97706; color: #fff; box-shadow: 0 2px 8px rgba(217,119,6,0.3); }
.risk-step-item.completed { color: var(--state-ok); }
.risk-step-item.failed    { color: var(--state-critical); background: rgba(239,68,68,0.05); }

.risk-step-indicator {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  flex-shrink: 0;
  transition: all 0.25s ease;
}

.risk-step-item.waiting   .risk-step-indicator { border: 1.5px solid var(--border-default); }
.risk-step-item.running   .risk-step-indicator { border: 2px solid rgba(255,255,255,0.5); border-top-color: #fff; animation: riskSpin 0.7s linear infinite; }
.risk-step-item.completed .risk-step-indicator { background: var(--state-ok); color: #fff; }
.risk-step-item.failed    .risk-step-indicator { background: var(--state-critical); color: #fff; }

@keyframes riskSpin { to { transform: rotate(360deg); } }

.risk-step-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.risk-step-name {
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
}

.risk-step-tool {
  font-size: 9px;
  opacity: 0.6;
  white-space: nowrap;
}

.risk-step-duration {
  font-size: 9.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.risk-step-item.waiting .risk-step-duration {
  display: none;
}

.risk-step-connector {
  width: 10px;
  height: 1.5px;
  background: var(--border-default);
  flex-shrink: 0;
  align-self: center;
  transition: background 0.3s ease;
}

.risk-step-connector.done {
  background: var(--state-ok);
}

/* ==========================================================================
   Compare Section
   ========================================================================== */

.risk-compare-section {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 14px 18px;
  flex-shrink: 0;
}

.risk-compare-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.risk-compare-item {
  text-align: center;
  padding: 12px 8px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.risk-compare-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 6px;
}

.risk-compare-values {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.risk-compare-before {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.risk-compare-arrow {
  font-size: 10px;
  color: var(--text-muted);
}

.risk-compare-after {
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.risk-compare-after.risk-down   { color: var(--state-ok); }
.risk-compare-after.risk-up     { color: var(--state-critical); }
.risk-compare-after.risk-warn   { color: #D97706; }
.risk-compare-after.risk-same   { color: var(--text-primary); }
.risk-compare-after.risk-placeholder { color: var(--text-muted); font-family: inherit; font-size: 11px; font-weight: 600; }
.risk-compare-note {
  margin-top: 5px;
  color: #0f9f75;
  font-size: 10px;
  line-height: 1.25;
}

/* ==========================================================================
   Mid Section (risk score + period)
   ========================================================================== */

.risk-mid-section {
  flex-shrink: 0;
}

.risk-mid-row {
  display: flex;
  gap: 12px;
}

.risk-score-card,
.risk-period-card {
  flex: 1;
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.risk-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.risk-card-header svg {
  color: #D97706;
  flex-shrink: 0;
}

.risk-card-body {
  padding: 14px;
  min-height: 80px;
  font-size: 12px;
  color: var(--text-secondary);
}

.risk-card-wait {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  color: var(--text-muted);
  font-size: 12px;
}

/* Risk Score */
.risk-score-display {
  display: flex;
  align-items: center;
  gap: 24px;
}

.risk-score-before,
.risk-score-after {
  text-align: center;
}

.risk-score-num {
  font-size: 36px;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1;
}

.risk-score-num.normal  { color: var(--state-ok); }
.risk-score-num.warning { color: #D97706; }
.risk-score-num.critical { color: var(--state-critical); }
.risk-score-num.risk-placeholder-text { color: var(--text-muted); font-family: inherit; font-size: 18px; }

.risk-score-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.risk-score-delta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.risk-score-delta-num {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.risk-score-delta-num.up   { color: var(--state-critical); }
.risk-score-delta-num.down { color: var(--state-ok); }

.risk-score-delta-label {
  font-size: 10px;
  color: var(--text-muted);
}

/* Risk Period */
.risk-period-display {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.risk-period-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.risk-period-label {
  width: 48px;
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}

.risk-period-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  position: relative;
}

.risk-period-bar.normal  { background: rgba(16,185,129,0.2); }
.risk-period-bar.warning { background: rgba(245,158,11,0.3); }
.risk-period-bar.critical { background: rgba(239,68,68,0.3); }
.risk-period-bar.risk-placeholder-bar { background: repeating-linear-gradient(90deg, #E2E8F0 0, #E2E8F0 8px, transparent 8px, transparent 14px); }

.risk-period-segment {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 3px;
}

.risk-period-segment.warning  { background: #F59E0B; }
.risk-period-segment.critical { background: #EF4444; }

.risk-period-text {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  width: 90px;
  text-align: right;
  flex-shrink: 0;
}

/* ==========================================================================
   Charts Section
   ========================================================================== */

.risk-charts-section {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 14px 18px;
  flex-shrink: 0;
}

.risk-chart-legend {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}

.risk-legend-dot {
  width: 10px;
  height: 3px;
  border-radius: 2px;
}

.risk-legend-dot.before { background: #94A3B8; margin-left: 8px; }
.risk-legend-dot.after  { background: #D97706; }
.risk-legend-dot.after.improved { background: #10B981; }
.risk-legend-dot.after.worsened { background: #EF4444; }
.risk-legend-dot.after.same { background: #D97706; }
.risk-legend-dot.after.pending { background: #CBD5E1; }

.risk-charts-row {
  display: flex;
  gap: 12px;
}

.risk-chart-card {
  flex: 1;
  min-width: 0;
  height: 240px;
}

.risk-chart-tooltip {
  min-width: 132px;
  padding: 7px 9px;
  border: 1px solid #dbe4ec;
  border-radius: 6px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 3px 12px rgba(15,23,42,.12);
  color: #334155;
  font-size: 10px;
  line-height: 1.35;
}

.risk-chart-tooltip-time {
  margin-bottom: 4px;
  color: #64748B;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.risk-chart-tooltip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  white-space: nowrap;
}

.risk-chart-tooltip-row span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.risk-chart-tooltip-row i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.risk-chart-tooltip-row i.before { background: #94A3B8; }
.risk-chart-tooltip-row i.after { background: #10B981; }

.risk-chart-tooltip-row strong {
  color: #1E293B;
  font-family: var(--font-mono);
  font-weight: 700;
}

/* ==========================================================================
   Plans Section
   ========================================================================== */

.risk-plans-section {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: 14px 18px;
  flex-shrink: 0;
}

.risk-plans-row {
  display: flex;
  gap: 12px;
}

.risk-plan-card {
  flex: 1;
  padding: 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.risk-plan-feasibility {
  font-size: 10px;
  font-weight: 600;
}

.risk-plan-feasibility.feasible { color: #059669; }
.risk-plan-feasibility.infeasible { color: #DC2626; }

.risk-plan-card:hover {
  border-color: #D97706;
  box-shadow: 0 2px 8px rgba(217,119,6,0.08);
}

.risk-plan-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.risk-plan-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

.risk-plan-badge.a { background: rgba(59,130,246,0.1);  color: #2563EB; }
.risk-plan-badge.b { background: rgba(16,185,129,0.1);  color: #059669; }
.risk-plan-badge.c { background: rgba(139,92,246,0.1);  color: #7C3AED; }

.risk-plan-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.risk-plan-metrics {
  display: flex;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 11px;
}

.risk-plan-metric-label {
  color: var(--text-muted);
}

.risk-plan-metric-value {
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.risk-plan-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.risk-plan-scenario {
  color: #64748B;
  font-size: 10px;
  margin: -2px 0 6px;
}

.risk-plan-parameters {
  margin-bottom: 7px;
}

.risk-plan-parameters-label {
  display: block;
  color: #64748B;
  font-size: 10px;
  margin-bottom: 4px;
}

.risk-plan-parameter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.risk-plan-parameter-chip,
.risk-plan-parameter-empty {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border: 1px solid #D9E3EC;
  border-radius: 999px;
  background: rgba(255,255,255,0.72);
  color: #64748B;
  font-size: 10px;
  line-height: 1.35;
}

.risk-plan-parameter-chip strong {
  color: #D97706;
  font-family: var(--font-mono);
  font-weight: 700;
}

.risk-plan-parameter-empty {
  color: #94A3B8;
}

.risk-plan-btn {
  padding: 5px 14px;
  font-size: 11px;
  font-weight: 600;
  color: #D97706;
  background: transparent;
  border: 1px solid rgba(217,119,6,0.3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.risk-plan-btn:hover {
  background: rgba(217,119,6,0.06);
  border-color: #D97706;
}

.risk-plan-btn:active {
  transform: scale(0.97);
}

/* ==========================================================================
   Animations
   ========================================================================== */

.risk-fade-in {
  animation: riskFadeIn 0.35s ease;
}

@keyframes riskFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.risk-pulse {
  animation: riskPulse 0.5s ease;
}

@keyframes riskPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .risk-step-item.running .risk-step-indicator { animation: none; border-top-color: rgba(255,255,255,0.5); }
  .risk-fade-in, .risk-pulse { animation: none; }
}

/* ======================================================================
   工业化风险驾驶舱增强层
   仅作用于风险推演页；保留原有数据结构和离线演示能力。
   ====================================================================== */

#page-risk {
  --risk-ink: #172235;
  --risk-muted: #718096;
  --risk-line: #d9e1ea;
  --risk-orange: #d97706;
  --risk-green: #10b981;
  background: #eef2f6;
}

#page-risk .risk-layout {
  gap: 0;
  background: #eef2f6;
}

#page-risk .risk-sidebar {
  width: 296px;
  background: #f7f9fb;
  border-right: 1px solid #dce4ec;
  box-shadow: inset -1px 0 0 rgba(255,255,255,.8);
}

#page-risk .risk-sidebar-header {
  height: 58px;
  padding: 0 20px;
  color: var(--risk-ink);
  border-bottom: 1px solid var(--risk-line);
  letter-spacing: .02em;
}

#page-risk .risk-sidebar-header svg,
#page-risk .risk-section-title svg {
  color: var(--risk-orange);
}

#page-risk .risk-config-section,
#page-risk .risk-source-task {
  margin-left: 14px;
  margin-right: 14px;
}

#page-risk .risk-config-label {
  color: #526174;
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
}

#page-risk .risk-main {
  padding: 15px 18px 24px;
  gap: 12px;
  background: #eef2f6;
}

#page-risk .risk-pipeline-section,
#page-risk .risk-compare-section,
#page-risk .risk-cause-section,
#page-risk .risk-charts-section,
#page-risk .risk-plans-section {
  border: 1px solid var(--risk-line);
  border-radius: 10px;
  box-shadow: 0 3px 12px rgba(30, 48, 70, .045);
  background: rgba(255,255,255,.94);
}

#page-risk .risk-pipeline-section {
  border-top: 3px solid var(--risk-orange);
}

#page-risk .risk-compare-section,
#page-risk .risk-cause-section {
  border-top: 2px solid #aab8c8;
}

#page-risk .risk-section-header {
  min-height: 42px;
  padding: 0 14px;
  border-bottom: 1px solid #e5ebf1;
}

#page-risk .risk-section-title {
  color: var(--risk-ink);
  font-size: 13px;
  letter-spacing: .015em;
}

#page-risk .risk-compare-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  padding: 12px 14px 14px;
}

#page-risk .risk-compare-item {
  min-height: 74px;
  padding: 13px 14px;
  border: 1px solid #e1e8ef;
  border-radius: 7px;
  background: linear-gradient(135deg, #f6f8fa 0%, #edf2f6 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.75);
}

#page-risk .risk-compare-label {
  color: #68778a;
  font-size: 10px;
  letter-spacing: .04em;
}

#page-risk .risk-compare-before,
#page-risk .risk-compare-after {
  font-family: var(--font-mono);
  font-size: 18px;
}

#page-risk .risk-cause-section {
  flex-shrink: 0;
  overflow: hidden;
}

#page-risk .risk-cause-source-pill {
  padding: 4px 9px;
  border: 1px solid #d9e1ea;
  border-radius: 999px;
  color: #7a8796;
  background: #f5f7f9;
  font-size: 10px;
  font-weight: 700;
}

#page-risk .risk-cause-source-pill.llm {
  color: #087f65;
  border-color: rgba(16,185,129,.3);
  background: rgba(16,185,129,.1);
}

#page-risk .risk-cause-source-pill.deterministic {
  color: #8a5a06;
  border-color: rgba(217,119,6,.26);
  background: rgba(217,119,6,.08);
}

#page-risk .risk-cause-body {
  padding: 13px 14px 15px;
}

/* 三合一结果摘要：把风险评分、风险时段和改善状态放在原因链上方，
   让用户先看结论，再阅读数据事实与语言解释。 */
#page-risk .risk-cause-overview {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(420px, 1.55fr) minmax(250px, .9fr);
  gap: 9px;
  margin-bottom: 12px;
}

#page-risk .risk-cause-overview-card {
  min-height: 82px;
  padding: 9px 12px;
  border: 1px solid #dfe7ee;
  border-radius: 7px;
  background: linear-gradient(135deg, #f7f9fb 0%, #edf3f6 100%);
}

#page-risk .risk-cause-overview-label,
#page-risk .risk-cause-overview-meta {
  display: block;
  color: #718096;
  font-size: 10px;
}

#page-risk .risk-cause-overview-values {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 30px;
  margin-top: 3px;
}

#page-risk .risk-cause-overview-values strong {
  color: #5d7188;
  font-family: var(--font-mono);
  font-size: 15px;
  white-space: nowrap;
}

#page-risk .risk-cause-overview-values strong.positive {
  color: #059669;
}

#page-risk .risk-cause-overview-values strong.negative,
#page-risk .risk-cause-score-row strong.negative {
  color: #dc2626;
}

#page-risk .risk-cause-overview-values span {
  color: #a0aec0;
  font-size: 12px;
}

#page-risk .risk-cause-overview-meta {
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#page-risk .risk-cause-level-row,
#page-risk .risk-cause-score-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 23px;
  margin-top: 2px;
}

#page-risk .risk-cause-level-row span,
#page-risk .risk-cause-score-row span {
  color: #718096;
  font-size: 10px;
  flex-shrink: 0;
}

#page-risk .risk-cause-level-row strong {
  color: #5d7188;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

#page-risk .risk-cause-score-row strong {
  color: #5d7188;
  font-family: var(--font-mono);
  font-size: 15px;
  white-space: nowrap;
}

#page-risk .risk-cause-period-card .risk-cause-overview-values {
  gap: 7px;
  min-height: 36px;
}

#page-risk .risk-cause-period-card .risk-cause-overview-values strong {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

#page-risk .risk-cause-overview-status {
  min-height: 30px;
  margin-top: 3px;
  color: #8a5a06;
  font-size: 16px;
  font-weight: 700;
  line-height: 30px;
}

#page-risk .risk-cause-overview-status.selected {
  color: #059669;
}

#page-risk .risk-cause-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
  align-items: start;
}

#page-risk .risk-cause-facts-chain {
  min-width: 0;
}

#page-risk .risk-cause-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

#page-risk .risk-cause-fact {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  min-height: 58px;
  padding: 8px 9px;
  border-left: 3px solid #c7d2de;
  border-radius: 4px;
  background: #f4f7fa;
  color: var(--risk-muted);
  font-size: 10px;
}

#page-risk .risk-cause-fact strong {
  color: var(--risk-ink);
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: normal;
  overflow-wrap: anywhere;
}

#page-risk .risk-cause-chain {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 74px;
  min-width: 0;
  margin-top: 0;
  padding: 10px 12px;
  overflow-x: auto;
  border: 1px solid #e1e8ef;
  border-radius: 6px;
  background: linear-gradient(90deg, #f8fafc, #eef4f5);
}

#page-risk .risk-cause-node {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid #c7d5df;
  border-radius: 5px;
  color: #39495d;
  background: #fff;
  font-size: 10px;
  line-height: 1.35;
  white-space: nowrap;
}

#page-risk .risk-cause-node.terminal {
  border-color: rgba(217,119,6,.35);
  color: #9a5a00;
  background: rgba(217,119,6,.08);
  font-weight: 700;
}

#page-risk .risk-cause-node.muted {
  color: #8b98a8;
  border-style: dashed;
}

#page-risk .risk-cause-arrow {
  color: var(--risk-orange);
  font-size: 14px;
  font-weight: 700;
}

#page-risk .risk-cause-narrative {
  min-width: 0;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  grid-template-rows: auto minmax(64px, auto) minmax(92px, 1fr);
  gap: 9px;
  align-items: stretch;
}

#page-risk .risk-cause-narrative > div {
  padding: 10px 11px;
  border-radius: 5px;
  background: #f5f8fa;
  color: #526174;
  font-size: 10.5px;
  line-height: 1.55;
}

#page-risk .risk-cause-narrative-label {
  grid-row: 1 / -1;
  display: flex;
  align-items: flex-start;
  color: #8a5a06 !important;
  background: rgba(217,119,6,.09) !important;
  font-weight: 700;
}

#page-risk .risk-cause-summary {
  color: var(--risk-ink) !important;
  font-weight: 700;
}

#page-risk .risk-cause-analysis {
  border-left: 3px solid #aebdca;
  max-height: 180px;
  overflow-y: auto;
}

#page-risk .risk-cause-conclusion {
  color: #087f65 !important;
  border-left: 3px solid var(--risk-green);
  max-height: 96px;
  overflow-y: auto;
}

#page-risk .risk-cause-analysis:focus,
#page-risk .risk-cause-conclusion:focus {
  outline: 2px solid rgba(59,130,246,.22);
  outline-offset: 1px;
}

#page-risk .risk-charts-section,
#page-risk .risk-plans-section {
  padding-top: 0;
}

#page-risk .risk-chart-card {
  height: 248px;
  border-radius: 0;
}

#page-risk .risk-plan-card {
  border-color: #dbe4ec;
  box-shadow: 0 2px 6px rgba(30,48,70,.03);
  min-height: 128px;
  padding: 11px 13px 10px;
  display: flex;
  flex-direction: column;
}

#page-risk .risk-plan-header {
  gap: 7px;
  margin-bottom: 7px;
}

#page-risk .risk-plan-badge {
  padding: 3px 9px;
  font-size: 10px;
}

#page-risk .risk-plan-title {
  font-size: 12px;
}

#page-risk .risk-plan-metrics {
  gap: 10px;
  margin-bottom: 6px;
  min-height: 16px;
}

#page-risk .risk-plan-desc {
  margin-bottom: 7px;
  font-size: 10px;
  line-height: 1.45;
  flex: 1;
}

#page-risk .risk-plan-btn {
  align-self: flex-start;
  padding: 4px 12px;
  font-size: 10px;
}

@media (max-width: 1100px) {
  #page-risk .risk-sidebar { width: 260px; }
  #page-risk .risk-cause-overview { grid-template-columns: 1fr; }
  #page-risk .risk-cause-layout { grid-template-columns: 1fr; }
  #page-risk .risk-cause-narrative { grid-template-columns: 112px minmax(0, 1fr); }
}

@media (max-width: 760px) {
  #page-risk .risk-sidebar { width: 220px; }
  #page-risk .risk-compare-grid,
  #page-risk .risk-plans-row,
  #page-risk .risk-charts-row { flex-wrap: wrap; }
  #page-risk .risk-compare-item,
  #page-risk .risk-plan-card,
  #page-risk .risk-chart-card { min-width: 100%; }
  #page-risk .risk-cause-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #page-risk .risk-cause-narrative { grid-template-columns: 1fr; grid-template-rows: auto; }
  #page-risk .risk-cause-narrative-label { grid-row: auto; }
}

/* ======================================================================
   当前版本最终布局规则
   原因解释区采用“左侧标签 + 中部总览 + 右侧上下证据”的三列结构。
   主工作区与左侧栏保持同高，主工作区使用唯一的纵向滚动轨道；只有较长的
   AI解释和事实链在内容内部滚动，保证底部方案卡片始终可到达。
   ====================================================================== */

#page-risk .risk-main {
  min-height: 0;
  height: 100%;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

#page-risk .risk-main::-webkit-scrollbar {
  width: 7px;
}

#page-risk .risk-main::-webkit-scrollbar-thumb {
  background: #b8c5d2;
  border-radius: 4px;
}

#page-risk .risk-main::-webkit-scrollbar-track {
  background: transparent;
}

#page-risk .risk-cause-score-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr);
  gap: 14px;
  align-items: end;
  min-height: 43px;
}

#page-risk .risk-cause-score-columns .risk-cause-level-row,
#page-risk .risk-cause-score-columns .risk-cause-score-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 3px;
  min-height: 43px;
  margin-top: 0;
}

#page-risk .risk-cause-score-columns .risk-cause-level-row strong,
#page-risk .risk-cause-score-columns .risk-cause-score-row strong {
  font-size: 14px;
  line-height: 1.2;
}

#page-risk .risk-cause-overview-meta {
  line-height: 1.35;
}

#page-risk .risk-cause-layout {
  grid-template-columns: 48px minmax(230px, .82fr) minmax(420px, 1.75fr);
  grid-template-rows: auto minmax(174px, 1fr);
  gap: 9px;
  min-height: 218px;
  align-items: stretch;
}

#page-risk .risk-cause-layout > .risk-cause-facts {
  grid-column: 1 / -1;
  grid-row: 1;
  min-width: 0;
}

#page-risk .risk-cause-layout > .risk-cause-narrative-label {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  border-left: 3px solid var(--risk-orange);
  border-radius: 5px;
  color: #8a5a06;
  background: rgba(217,119,6,.09);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1.35;
}

#page-risk .risk-cause-layout > .risk-cause-summary {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  padding: 12px 14px;
  overflow-y: auto;
  border-radius: 5px;
  background: #f5f8fa;
  color: var(--risk-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.7;
}

#page-risk .risk-cause-summary-kicker {
  margin-bottom: 7px;
  color: #a16207;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
}

#page-risk .risk-cause-summary-text {
  color: var(--risk-ink);
}

#page-risk .risk-cause-summary-detail {
  margin-top: 11px;
  padding-top: 9px;
  border-top: 1px solid #dbe4ec;
  color: #526174;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.65;
}

#page-risk .risk-cause-evidence {
  grid-column: 3;
  grid-row: 2;
  display: grid;
  grid-template-rows: minmax(62px, auto) minmax(96px, 1fr);
  gap: 9px;
  min-width: 0;
  min-height: 0;
}

#page-risk .risk-cause-evidence .risk-cause-chain {
  min-height: 62px;
  margin: 0;
  padding: 8px 10px;
  overflow-x: auto;
  overflow-y: hidden;
}

#page-risk .risk-cause-evidence .risk-cause-analysis {
  min-height: 0;
  max-height: none;
  margin: 0;
  padding: 10px 11px;
  overflow-y: auto;
  border-left: 3px solid #aebdca;
  border-radius: 5px;
  background: #f5f8fa;
  color: #526174;
  font-size: 10.5px;
  line-height: 1.55;
}

#page-risk .risk-cause-conclusion {
  display: none !important;
}

#page-risk .risk-cause-summary:focus,
#page-risk .risk-cause-analysis:focus {
  outline: 2px solid rgba(59,130,246,.22);
  outline-offset: 1px;
}

@media (max-width: 1100px) {
  #page-risk .risk-cause-layout {
    grid-template-columns: 42px minmax(190px, .8fr) minmax(320px, 1.5fr);
  }
}

@media (max-width: 760px) {
  #page-risk .risk-main {
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  #page-risk .risk-cause-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(170px, 1fr) minmax(200px, 1fr);
  }

  #page-risk .risk-cause-layout > .risk-cause-facts {
    grid-column: 1;
    grid-row: 1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #page-risk .risk-cause-layout > .risk-cause-narrative-label {
    grid-column: 1;
    grid-row: 2;
    writing-mode: horizontal-tb;
    min-height: 34px;
    padding: 8px 10px;
  }

  #page-risk .risk-cause-layout > .risk-cause-summary {
    grid-column: 1;
    grid-row: 3;
  }

  #page-risk .risk-cause-evidence {
    grid-column: 1;
    grid-row: 4;
  }
}
