/* app.css
   Tower Balance Lab v0.2 本地样式
   风格：简洁、清晰、明了，不强制深色
*/

:root {
  --tb-border: #e5e7eb;
  --tb-muted: #6b7280;
  --tb-bg: #f8fafc;
}

body {
  background-color: var(--tb-bg);
}

.app-header {
  background-color: #fff;
  border-bottom: 1px solid var(--tb-border);
}

/* Tab 面板切换 */
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* 空状态 */
.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--tb-muted);
  border: 1px dashed var(--tb-border);
  border-radius: 4px;
  background: #fff;
}

/* 占位面板 */
.placeholder-panel {
  padding: 2rem;
  text-align: center;
  font-size: 1.05rem;
}

/* 统计卡片 */
.stat-card {
  min-width: 110px;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  background: #fff;
  border: 1px solid var(--tb-border);
  text-align: center;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--tb-muted);
  margin-bottom: 0.25rem;
}
.stat-value {
  font-size: 1.25rem;
  font-weight: 600;
}
.stat-primary { border-left: 3px solid #206bc4; }
.stat-info    { border-left: 3px solid #4299e1; }
.stat-success { border-left: 3px solid #2fb344; }
.stat-warning { border-left: 3px solid #f59f00; }
.stat-danger  { border-left: 3px solid #d63939; }

/* 异常列表 */
.issue-list {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--tb-border);
  border-radius: 4px;
  background: #fff;
  padding: 0.5rem;
}
.issue-item {
  padding: 0.25rem 0;
  font-size: 0.875rem;
  border-bottom: 1px solid #f1f5f9;
}
.issue-item:last-child {
  border-bottom: none;
}

/* 表格区域 */
.table-area {
  min-height: 120px;
  position: relative;
  max-width: 100%;
}

/* 主表表头：压缩主题默认的 12px 横向内边距，并为可排序列保留独立箭头区。 */
#placeable-table .tabulator-header .tabulator-col .tabulator-col-content {
  padding-left: 6px;
  padding-right: 6px;
}
#placeable-table .tabulator-header .tabulator-col .tabulator-col-title {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: clip !important;
  width: 100% !important;
  padding-right: 0 !important;
  display: block !important;
  box-sizing: border-box !important;
}
#placeable-table .tabulator-header .tabulator-col.tabulator-sortable .tabulator-col-title {
  padding-right: 20px !important;
}
#placeable-table .tabulator-header .tabulator-col.tabulator-sortable .tabulator-col-sorter {
  position: absolute;
  right: 0;
  width: 12px;
}

/* 等级按钮组（Tab 2 单行 + Lv1/Lv2/Lv3 切换） */
.level-btn-group {
  display: inline-flex;
  gap: 0.25rem;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.level-btn {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  line-height: 1.2;
  border: 1px solid var(--tb-border);
  border-radius: 3px;
  background: #fff;
  color: #6b7280;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
  height: 24px;
}
.level-btn:hover {
  background: #eef2f7;
  color: #206bc4;
  border-color: #206bc4;
}
.level-btn.active {
  background: #206bc4;
  color: #fff;
  border-color: #206bc4;
}

/* ========== v0.3 暂存编辑状态栏 ========== */
.edit-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  background: #fff;
  border: 1px solid var(--tb-border);
  border-radius: 4px;
  flex-wrap: wrap;
}
.edit-status-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.edit-status-info .badge {
  color: #fff !important;
  font-weight: 600;
}
.edit-status-actions {
  display: flex;
  gap: 0.5rem;
}
.edit-notice {
  font-size: 0.8rem;
}

/* ========== v0.3 已修改单元格 / 行高亮 ========== */
.modified-cell {
  background: #fff3cd;
  color: #806000;
  font-weight: 600;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  display: inline-block;
}
/* fallback 原生 input 编辑框 */
.fallback-edit-input {
  height: 28px;
  padding: 0.25rem 0.4rem;
  font-size: 0.8125rem;
  line-height: 1.2;
  border: 1px solid #d1d5db;
  border-radius: 3px;
  width: 100%;
  box-sizing: border-box;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.fallback-edit-input:focus {
  border-color: #206bc4;
  outline: none;
  box-shadow: 0 0 0 2px rgba(32, 107, 196, 0.12);
}
input.fallback-edit-input.modified-cell {
  background: #fff3cd;
  border-color: #f59f00;
  color: #806000;
  font-weight: 600;
}
/* fallback 原生表格行已修改 */
.native-table tbody tr.modified-row {
  background: #fff8e1;
}
.native-table tbody tr.modified-row td {
  background: #fff8e1;
}
/* Tabulator 单元格已修改（formatter span 已加 modified-cell，这里给整 td 加背景） */
.tabulator-table td .modified-cell {
  background: #fff3cd;
}

/* ========== v0.3 不可编辑单元格（原始 JSON 无对应槽位） ========== */
.disabled-cell {
  color: #9ca3af;
  background: #f5f5f5;
  cursor: not-allowed;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  display: inline-block;
}
/* fallback 原生 input 不可编辑 */
input.fallback-edit-input.disabled-cell {
  background: #f5f5f5;
  border-color: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
  text-align: right;
}
input.fallback-edit-input.disabled-cell:disabled {
  opacity: 0.7;
}
/* Tabulator 单元格不可编辑 */
.tabulator-table td .disabled-cell {
  background: #f5f5f5;
}

/* ========== v0.4 Tab 4 风险列表筛选 ========== */
.rule-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.rule-filter-btn {
  font-weight: 500;
}
.rule-filter-btn.btn-active {
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08) inset;
}
.rule-filter-btn.btn-outline-danger.btn-active {
  background: #dc3545;
  color: #fff;
  border-color: #dc3545;
}
.rule-filter-btn.btn-outline-warning.btn-active {
  background: #f59f00;
  color: #212529;
  border-color: #f59f00;
}
.rule-filter-btn.btn-outline-secondary.btn-active {
  background: #6c757d;
  color: #fff;
  border-color: #6c757d;
}

/* 概览卡片可点击（danger/warning 卡片触发筛选） */
.stat-card-clickable {
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.08s ease;
}
.stat-card-clickable:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.stat-card-clickable-active {
  background: #f3f4f6 !important;
  box-shadow: 0 0 0 2px #206bc4 inset;
}
.stat-card-clickable-active.stat-danger {
  box-shadow: 0 0 0 2px #dc3545 inset;
}
.stat-card-clickable-active.stat-warning {
  box-shadow: 0 0 0 2px #f59f00 inset;
}

/* ========== v0.5 Tab 5 范围可视化 ========== */
.range-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.range-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: flex-start;
  padding: 0.75rem 1rem;
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.range-control-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.range-control-label {
  font-weight: 600;
  color: #374151;
  margin-right: 0.25rem;
}
.range-level-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.range-unit-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  user-select: none;
}
.range-unit-checkbox.checked {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
}
.range-unit-checkbox input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}
.range-unit-checkbox input[type="checkbox"]:disabled {
  cursor: not-allowed;
}
.range-body {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
}
.range-svg-wrap {
  flex: 0 0 auto;
  width: 480px;
  max-width: 100%;
}
.range-svg {
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.range-legend {
  flex: 1 1 200px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.range-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: #374151;
}
.range-legend-swatch {
  display: inline-block;
  width: 28px;
  height: 14px;
  border-radius: 2px;
}
.range-legend-solid {
  background: transparent;
  border: 2px solid #2563eb;
}
.range-legend-dashed {
  background: transparent;
  border: 2px dashed #2563eb;
  opacity: 0.6;
}
.range-legend-note {
  font-size: 0.78rem;
  color: #6b7280;
  margin-top: 0.25rem;
  line-height: 1.4;
}
.range-table-wrap {
  overflow-x: auto;
  max-width: 100%;
}
.range-table th,
.range-table td {
  white-space: nowrap;
}
.range-table td:nth-child(3),
.range-table td:nth-child(4),
.range-table td:nth-child(5),
.range-table td:nth-child(6),
.range-table td:nth-child(7) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* 图表容器 */
.chart-box {
  height: 320px;
  position: relative;
}

/* badge 软色 */
.bg-primary-soft {
  background-color: rgba(32, 107, 196, 0.12);
  color: #206bc4;
}

/* 页脚 */
.footer {
  padding: 1rem 0;
  border-top: 1px solid var(--tb-border);
  background: #fff;
}

/* ========== CDN 降级样式 ========== */

/* 降级提示 */
.fallback-notice {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 4px;
  color: #806000;
  font-size: 0.875rem;
}

/* 原生表格容器（支持横向滚动） */
.native-table-wrap {
  overflow-x: auto;
  max-height: 520px;
  overflow-y: auto;
  border: 1px solid var(--tb-border);
  border-radius: 4px;
  background: #fff;
  max-width: 100%;
}

/* 原生表格 */
.native-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.native-table thead {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 10;
}
.native-table th,
.native-table td {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid #e5e7eb;
  border-right: 1px solid #f1f5f9;
  text-align: left;
  white-space: nowrap;
  height: 38px;
  vertical-align: middle;
}
.native-table th {
  font-weight: 600;
  color: #374151;
  font-size: 0.8125rem;
  height: 36px;
}
.native-table tbody tr:hover {
  background: #f9fafb;
}
.native-table td.text-right,
.native-table th.text-right {
  text-align: right;
}
.native-table td.text-center,
.native-table th.text-center {
  text-align: center;
}
.native-table td.text-truncate,
.native-table th.text-truncate {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.native-table td.text-wrap {
  white-space: normal;
  line-height: 1.35;
  min-width: 260px;
  max-width: 360px;
}

/* 简易图表容器 */
.simple-chart {
  padding: 0.5rem;
  background: #fff;
  border: 1px solid var(--tb-border);
  border-radius: 4px;
  max-height: 300px;
  overflow-y: auto;
}
.simple-chart-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}
.simple-chart-group {
  font-weight: 600;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #374151;
  border-top: 1px dashed #e5e7eb;
  padding-top: 0.25rem;
}
.simple-chart-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.15rem 0;
  font-size: 0.8rem;
}
.simple-chart-label {
  flex: 0 0 90px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.simple-chart-bar {
  display: inline-block;
  height: 14px;
  background: #206bc4;
  border-radius: 2px;
  min-width: 2px;
  flex: 1 1 auto;
  max-width: 100%;
}
.simple-chart-value {
  flex: 0 0 auto;
  min-width: 48px;
  text-align: right;
  color: #374151;
  font-variant-numeric: tabular-nums;
}

/* ========== v0.6 Tab 1 总览工作台 dashboard ========== */
.dashboard-card {
  border-left: 3px solid #206bc4;
}
.dashboard-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.dashboard-stat-text {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}
/* 工作流步骤 */
.dashboard-workflow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
}
.dashboard-workflow-step {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background: #fff;
  border: 1px solid var(--tb-border);
  border-radius: 20px;
  font-size: 0.9rem;
  color: #374151;
}
.dashboard-workflow-step.clickable {
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.dashboard-workflow-step.clickable:hover {
  background: #eef2f7;
  border-color: #206bc4;
  color: #206bc4;
}
.dashboard-workflow-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #206bc4;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
}
.dashboard-workflow-label {
  font-weight: 500;
}
.dashboard-workflow-arrow {
  color: var(--tb-muted);
  font-size: 1rem;
  font-weight: 600;
}

/* ========== v0.9.2 Tab 1 次级折叠摘要 ========== */
.dashboard-secondary-details {
  border: 1px solid var(--tb-border);
  border-radius: 6px;
  background: #fff;
}
.dashboard-secondary-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  list-style: none;
}
.dashboard-secondary-summary::-webkit-details-marker {
  display: none;
}
.dashboard-secondary-title {
  font-weight: 600;
  color: #374151;
}
.dashboard-summary-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  font-size: 0.8125rem;
}
.dash-metric {
  color: #6b7280;
  white-space: nowrap;
}
.dash-metric-danger {
  color: #dc3545;
  font-weight: 600;
}
.dash-metric-warning {
  color: #f59f00;
  font-weight: 600;
}
.dashboard-secondary-content {
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-top: 1px solid var(--tb-border);
}
.dashboard-secondary-content .dashboard-card {
  border-left: 3px solid #cbd5e1;
  box-shadow: none;
}
.dashboard-secondary-content .card-header {
  min-height: 42px;
  padding: 10px 16px;
}
.dashboard-secondary-content .card-body {
  padding: 12px 16px;
}
.dashboard-secondary-content .stat-card {
  padding: 0.35rem 0.5rem;
  min-width: 90px;
}
.dashboard-secondary-content .stat-value {
  font-size: 1.1rem;
}

/* ========== v0.7 Tab 3 基础数值可视化大盘 ========== */
.charts-section-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #374151;
  margin: 0.75rem 0 0.5rem 0;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid #206bc4;
}
.charts-summary-cards .summary-card {
  min-width: 130px;
}
.summary-value-num {
  font-size: 1.15rem;
  font-weight: 700;
  color: #206bc4;
  font-variant-numeric: tabular-nums;
}
.summary-name {
  font-size: 0.78rem;
  color: var(--tb-muted);
  margin-top: 0.15rem;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-title-main {
  color: inherit;
}
.chart-title-meaning {
  color: #f59e0b;
  font-size: 0.9em;
  font-weight: 600;
  margin-left: 0.3em;
}
.chart-axis-explanation {
  margin-top: 3px;
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 400;
}
.unit-level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 22px;
  padding: 0 8px;
  margin-left: 6px;
  border: 1px solid #b9d3f3;
  border-radius: 999px;
  background: #eef6ff;
  color: #1769c2;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}

/* ========== v0.7.1 Tab 3 子页/等级筛选/重点单位卡/折叠区 ========== */

/* 子页导航 */
.charts-subtab-nav {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: #f8fafc;
  border: 1px solid var(--tb-border);
  border-radius: 6px;
}
.charts-subtab-btn {
  padding: 0.3rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.charts-subtab-btn:hover {
  background: #eef2f7;
  color: #206bc4;
}
.charts-subtab-btn.active {
  background: #206bc4;
  color: #fff;
  border-color: #206bc4;
}

/* 等级筛选 */
.charts-level-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.75rem;
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.charts-level-label {
  font-weight: 600;
  color: #374151;
  margin-right: 0.25rem;
}
.charts-level-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* 重点单位卡 */
.focus-unit-card {
  border-left: 3px solid #2fb344;
  height: 100%;
}
.focus-unit-name {
  font-size: 1rem;
  font-weight: 700;
  color: #206bc4;
  margin-bottom: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #e5e7eb;
}
.focus-unit-stats {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.focus-unit-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  padding: 0.1rem 0;
}
.focus-unit-stat-label {
  color: var(--tb-muted);
  flex: 0 0 auto;
}
.focus-unit-stat-value {
  font-weight: 600;
  color: #374151;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* 等级成长折叠区 */
.charts-growth-details {
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}
.charts-growth-details > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.charts-growth-details > summary::-webkit-details-marker {
  display: none;
}
.charts-growth-details > summary::before {
  content: '▶ ';
  font-size: 0.7rem;
  color: var(--tb-muted);
  transition: transform 0.15s;
  display: inline-block;
}
.charts-growth-details[open] > summary::before {
  content: '▼ ';
}
.charts-growth-details[open] > summary {
  margin-bottom: 0.5rem;
}

/* 主图大尺寸容器 */
.chart-box-lg {
  height: 420px;
}

/* ========== v0.8 Tab 5 范围/接敌子页 ========== */

/* Tab 5 子页切换导航（浅色，与外层一致） */
.range-subtab-nav {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: #f8fafc;
  border: 1px solid var(--tb-border);
  border-radius: 6px;
}
.range-subtab-btn {
  padding: 0.3rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid #d8e0ea;
  border-radius: 4px;
  background: #fff;
  color: #475569;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.range-subtab-btn:hover {
  background: #f8fafc;
  color: #1769c2;
  border-color: #2f80d1;
}
.range-subtab-btn.active {
  background: #fff;
  color: #1769c2;
  border-color: #2f80d1;
  box-shadow: 0 1px 3px rgba(47, 128, 209, 0.16);
  font-weight: 600;
}

/* 接敌推演：浅色卡片风格，与全站一致 */
.engagement-simulation {
  background: transparent;
  color: #374151;
  padding: 16px;
  border-radius: 8px;
  border: none;
  font-size: 0.85rem;
}

/* 顶部标题区 */
.engagement-header {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.engagement-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.engagement-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}
.engagement-subtitle {
  font-size: 0.8rem;
  color: #6b7280;
  max-width: 520px;
}
.engagement-formula {
  background: #f0f4f8;
  border: 1px solid #d1d9e6;
  border-radius: 6px;
  padding: 10px 12px;
  max-width: 520px;
  font-size: 0.8rem;
  color: #475569;
  line-height: 1.5;
}
.engagement-formula-muted {
  color: #6b7280;
  margin-top: 4px;
}
.engagement-disclaimer {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: #fef9ee;
  border: 1px solid #f5e6b8;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 0.78rem;
  color: #92400e;
  line-height: 1.45;
}
.engagement-disclaimer-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f59f00;
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 参数栏：横向紧凑工具栏 */
.engagement-params {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: flex-end;
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.engagement-param-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}
.engagement-param-group-level,
.engagement-param-group-action {
  align-items: center;
}
.engagement-param-label {
  font-size: 0.72rem;
  color: #475569;
  font-weight: 500;
  white-space: nowrap;
}
.engagement-param-input {
  width: 78px;
  background: #fff;
  border: 1px solid #d1d5db;
  color: #1e293b;
  font-size: 0.82rem;
  padding: 0.2rem 0.4rem;
  height: calc(1.5em + 0.5rem + 2px);
  border-radius: 4px;
}
.engagement-param-input:focus {
  background: #fff;
  border-color: #2563eb;
  color: #1e293b;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.engagement-level-btn-group {
  display: inline-flex;
  gap: 0.15rem;
}
.engagement-level-btn {
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}
.engagement-level-btn:hover {
  border-color: #2563eb;
  color: #1e40af;
}
.engagement-level-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.engagement-layout {
  display: block;
  min-width: 0;
}
.engagement-main {
  width: 100%;
  min-width: 0;
}

/* 摘要区域：桌面两列，说明卡跨整行 */
.engagement-summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.engagement-summary-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px;
  min-width: 0;
}
.engagement-notes-card {
  grid-column: 1 / -1;
}
@media (max-width: 900px) {
  .engagement-summary-grid {
    grid-template-columns: 1fr;
  }
  .engagement-notes-card {
    grid-column: auto;
  }
}

/* 矩阵面板 */
.engagement-matrix-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px;
}
.engagement-matrix-title,
.engagement-side-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}
.engagement-matrix-subtitle,
.engagement-side-subtitle {
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 12px;
  line-height: 1.45;
}

/* 矩阵滚动容器 */
.engagement-matrix-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 4px;
  margin-bottom: 12px;
}
.engagement-matrix-table {
  width: max-content;
  margin-left: auto;
  margin-right: auto;
  border-collapse: separate;
  border-spacing: 5px;
  font-size: 0.72rem;
  table-layout: fixed;
}
.engagement-corner {
  width: 90px;
  min-width: 90px;
  background: #f8fafc;
  position: sticky;
  left: 0;
  top: 0;
  z-index: 4;
  border: none;
}
.engagement-col-header {
  width: 88px;
  min-width: 88px;
  height: 108px;
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafc;
  vertical-align: bottom;
  padding: 0 0 10px 0;
  border: none;
}
.engagement-col-header-text {
  display: inline-block;
  white-space: nowrap;
  color: #475569;
  font-size: 0.74rem;
  font-weight: 500;
  padding-left: 8px;
  padding-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}
.engagement-row-header {
  width: 92px;
  min-width: 92px;
  position: sticky;
  left: 0;
  z-index: 2;
  background: #f8fafc;
  text-align: left;
  padding: 0 10px;
  border: none;
}
.engagement-row-header-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #475569;
  font-size: 0.8rem;
  font-weight: 500;
}
.engagement-cell {
  width: 88px;
  min-width: 88px;
  height: 86px;
  border-radius: 6px;
  padding: 6px 4px;
  text-align: center;
  vertical-align: middle;
  color: inherit;
  line-height: 1.3;
  position: relative;
  overflow: hidden;
}
.engagement-cell-diagonal::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px dashed rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  pointer-events: none;
}
.engagement-cell-status {
  font-size: 0.82rem;
  font-weight: 800;
  margin-bottom: 3px;
  letter-spacing: 0.02em;
}
.engagement-cell-delta {
  font-size: 0.72rem;
  color: inherit;
  font-variant-numeric: tabular-nums;
  margin-bottom: 1px;
}
.engagement-cell-free-damage {
  font-size: 0.74rem;
  font-weight: 700;
  color: inherit;
  font-variant-numeric: tabular-nums;
  margin-bottom: 1px;
}
.engagement-cell-times {
  font-size: 0.68rem;
  color: inherit;
  font-variant-numeric: tabular-nums;
}

/* 图例 */
.engagement-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  font-size: 0.75rem;
  color: #475569;
}
.engagement-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.engagement-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}
.engagement-legend-note {
  color: #6b7280;
  font-size: 0.72rem;
}

/* 摘要卡排行条 */
.engagement-rank-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.engagement-rank-row {
  display: grid;
  grid-template-columns: 130px minmax(100px, 1fr) 70px;
  gap: 8px;
  align-items: center;
  font-size: 0.78rem;
}
.engagement-rank-label {
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.engagement-rank-bar-wrap {
  position: relative;
  height: 14px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}
.engagement-rank-bar-wrap-zero {
  overflow: visible;
}
.engagement-rank-zero-line {
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: -2px;
  width: 1px;
  background: rgba(0, 0, 0, 0.2);
  z-index: 2;
  pointer-events: none;
}
.engagement-rank-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 3px;
  transition: width 0.2s ease;
  z-index: 1;
}
.engagement-rank-bar-positive {
  background: #60a5fa;
}
.engagement-rank-bar-negative {
  background: #fb923c;
}
.engagement-rank-bar-purple {
  background: #c084fc;
}
.engagement-rank-value {
  color: #374151;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.engagement-rank-axis-label {
  text-align: center;
  font-size: 0.72rem;
  color: #6b7280;
  margin-top: 8px;
  letter-spacing: 0.05em;
}

/* 说明卡片 */
.engagement-notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}
@media (max-width: 900px) {
  .engagement-notes {
    grid-template-columns: 1fr;
  }
}
.engagement-note-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 0.78rem;
  color: #374151;
  line-height: 1.45;
}
.engagement-note-num {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

/* 空状态在深色主题下的调整 */
.engagement-simulation .empty-state {
  background: #f9fafb;
  border-color: #e5e7eb;
  color: #6b7280;
}
.engagement-simulation .alert-danger {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

/* ========== B3 轻量 1v1 结算面板 ========== */
.engagement-b3-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px;
  margin-top: 10px;
}
.engagement-b3-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}
.engagement-b3-subtitle {
  font-size: 0.78rem;
  color: #6b7280;
  margin-bottom: 10px;
}
.engagement-b3-prompt {
  font-size: 0.82rem;
  color: #6b7280;
  padding: 8px 0;
}
.engagement-b3-result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}
.engagement-b3-side {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.engagement-b3-side-label {
  font-size: 0.7rem;
  color: #6b7280;
}
.engagement-b3-side-name {
  font-weight: 600;
  color: #1e293b;
}
.engagement-b3-vs {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 600;
}
.engagement-b3-status {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e40af;
  padding: 6px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
}
.engagement-b3-table {
  width: 100%;
  font-size: 0.82rem;
}
.engagement-b3-warnings {
  margin-top: 8px;
  font-size: 0.75rem;
  color: #dc2626;
}
.engagement-b3-disclaimer {
  margin-top: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.72rem;
  color: #475569;
  line-height: 1.45;
}

/* ========== v0.9 两两接触矩阵（与接敌推演矩阵共享结构） ========== */

/* 公共矩阵结构：通过分组选择器统一尺寸、sticky、标题等 */
.engagement-corner,
.contact-matrix-corner {
  width: 90px;
  min-width: 90px;
  background: #f8fafc;
  position: sticky;
  left: 0;
  top: 0;
  z-index: 4;
  border: none;
}
.engagement-col-header,
.contact-matrix-col-header {
  width: 88px;
  min-width: 88px;
  height: 108px;
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafc;
  vertical-align: bottom;
  padding: 0 0 10px 0;
  border: none;
}
.engagement-col-header-text,
.contact-matrix-col-header-text {
  display: inline-block;
  white-space: nowrap;
  color: #475569;
  font-size: 0.74rem;
  font-weight: 500;
  padding-left: 8px;
  padding-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 88px;
}
.engagement-row-header,
.contact-matrix-row-header {
  width: 92px;
  min-width: 92px;
  position: sticky;
  left: 0;
  z-index: 2;
  background: #f8fafc;
  text-align: left;
  padding: 0 10px;
  border: none;
}
.engagement-row-header-text,
.contact-matrix-row-header-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #475569;
  font-size: 0.8rem;
  font-weight: 500;
}
.engagement-cell,
.contact-matrix-cell {
  width: 88px;
  min-width: 88px;
  height: 86px;
  border-radius: 6px;
  padding: 6px 4px;
  text-align: center;
  vertical-align: middle;
  color: inherit;
  line-height: 1.35;
  position: relative;
  overflow: hidden;
}
.engagement-cell-status,
.contact-matrix-cell-status {
  font-size: 0.84rem;
  font-weight: 800;
  margin-bottom: 3px;
  letter-spacing: 0.02em;
}
.engagement-cell-delta,
.engagement-cell-free-damage,
.engagement-cell-times,
.contact-matrix-cell-line {
  font-size: 0.72rem;
  color: inherit;
  font-variant-numeric: tabular-nums;
  margin-bottom: 1px;
}
.engagement-legend,
.contact-matrix-legend,
.contact-matrix-legend-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  font-size: 0.75rem;
  color: #475569;
}
.engagement-legend-item,
.contact-matrix-legend-item,
.contact-matrix-legend-inline .contact-matrix-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.engagement-legend-swatch,
.contact-matrix-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}
.engagement-legend-note,
.contact-matrix-legend-note {
  color: #6b7280;
  font-size: 0.72rem;
}

.contact-matrix-root {
  background: transparent;
  color: #374151;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
  font-size: 0.85rem;
}

/* 头部 */
.contact-matrix-header {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.contact-matrix-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}
.contact-matrix-subtitle {
  font-size: 0.8rem;
  color: #6b7280;
  max-width: 720px;
  line-height: 1.5;
}

/* 控件栏 */
.contact-matrix-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  margin-top: 12px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.contact-matrix-control-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.contact-matrix-control-label {
  font-size: 0.74rem;
  color: #475569;
  font-weight: 500;
  white-space: nowrap;
}
.contact-matrix-level-group {
  display: inline-flex;
  gap: 0.15rem;
}
.contact-matrix-level-btn {
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}
.contact-matrix-level-btn:hover {
  border-color: #2563eb;
  color: #1e40af;
}
.contact-matrix-level-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

/* 内联图例 */
.contact-matrix-legend-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  margin-top: 12px;
  font-size: 0.74rem;
  color: #475569;
}

/* 矩阵面板 */
.contact-matrix-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px;
}
.contact-matrix-panel-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}
.contact-matrix-panel-subtitle {
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 12px;
  line-height: 1.45;
}

/* 滚动容器 */
.contact-matrix-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 4px;
  margin-bottom: 12px;
}
.contact-matrix-table {
  width: max-content;
  margin-left: auto;
  margin-right: auto;
  border-collapse: separate;
  border-spacing: 5px;
  font-size: 0.72rem;
  table-layout: fixed;
}

/* 表头 */
.contact-matrix-corner {
  width: 90px;
  min-width: 90px;
  background: #f8fafc;
  position: sticky;
  left: 0;
  top: 0;
  z-index: 4;
  border: none;
}
.contact-matrix-col-header {
  width: 88px;
  min-width: 88px;
  height: 108px;
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8fafc;
  vertical-align: bottom;
  padding: 0 0 10px 0;
  border: none;
}
.contact-matrix-col-header-text {
  display: inline-block;
  white-space: nowrap;
  color: #475569;
  font-size: 0.74rem;
  font-weight: 500;
  padding-left: 8px;
  padding-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}
.contact-matrix-row-header {
  width: 92px;
  min-width: 92px;
  position: sticky;
  left: 0;
  z-index: 2;
  background: #f8fafc;
  text-align: left;
  padding: 0 10px;
  border: none;
}
.contact-matrix-row-header-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #475569;
  font-size: 0.8rem;
  font-weight: 500;
}

/* 单元格 */
.contact-matrix-cell {
  width: 88px;
  min-width: 88px;
  height: 86px;
  border-radius: 6px;
  padding: 6px 4px;
  text-align: center;
  vertical-align: middle;
  color: inherit;
  line-height: 1.35;
  position: relative;
  overflow: hidden;
}
.contact-matrix-cell-status {
  font-size: 0.86rem;
  font-weight: 800;
  margin-bottom: 3px;
  letter-spacing: 0.02em;
}
.contact-matrix-cell-line {
  font-size: 0.72rem;
  color: inherit;
  font-variant-numeric: tabular-nums;
  margin-bottom: 1px;
}

/* 图例 */
.contact-matrix-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  font-size: 0.75rem;
  color: #475569;
}
.contact-matrix-legend-inline .contact-matrix-legend-item,
.contact-matrix-legend .contact-matrix-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.contact-matrix-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}
.contact-matrix-legend-note {
  color: #6b7280;
  font-size: 0.72rem;
}

/* 空状态与提示 */
.contact-matrix-root .empty-state {
  background: #f9fafb;
  border-color: #e5e7eb;
  color: #6b7280;
}
.contact-matrix-root .alert-danger {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

/* ========== v1.0 修改前后对比 ========== */
.change-review-root {
  background: #fff;
  border: 1px solid var(--tb-border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
}
.change-review-title {
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
  margin: 0 0 0.5rem 0;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid #206bc4;
}
.change-review-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: #374151;
}
.change-review-stat {
  white-space: nowrap;
}
.change-review-increase strong {
  color: #2563eb;
}
.change-review-decrease strong {
  color: #ea580c;
}
.change-review-empty {
  padding: 1rem 0.5rem;
  text-align: center;
  color: var(--tb-muted);
  font-size: 0.875rem;
}
.change-review-table-wrap {
  overflow-x: auto;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--tb-border);
  border-radius: 4px;
}
.change-review-table {
  width: 100%;
  min-width: 580px;
  font-size: 0.8125rem;
}
.change-review-table th,
.change-review-table td {
  padding: 0.35rem 0.55rem;
  white-space: nowrap;
  height: 32px;
}
.change-delta-positive {
  color: #2563eb;
  font-weight: 600;
}
.change-delta-negative {
  color: #ea580c;
  font-weight: 600;
}

/* ========== v1.0 Tab 3 子页导航（白底分段按钮，与 Tab 5 一致） ========== */
.audit-subtab-nav {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: #f8fafc;
  border: 1px solid var(--tb-border);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}
.audit-subtab-btn {
  padding: 0.3rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid #d8e0ea;
  border-radius: 4px;
  background: #fff;
  color: #475569;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.audit-subtab-btn:hover {
  background: #f8fafc;
  color: #1769c2;
  border-color: #2f80d1;
}
.audit-subtab-btn.active {
  background: #fff;
  color: #1769c2;
  border-color: #2f80d1;
  box-shadow: 0 1px 3px rgba(47, 128, 209, 0.16);
  font-weight: 600;
}

/* ========== v1.0 等级成长审查 ========== */
.growth-review-root {
  background: #fff;
  border: 1px solid var(--tb-border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
}
.growth-review-title {
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
  margin: 0 0 0.5rem 0;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid #206bc4;
}
.growth-review-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: #374151;
}
.growth-review-stat {
  white-space: nowrap;
}
.growth-review-decline strong {
  color: #7c3aed;
}
.growth-review-jump strong {
  color: #ea580c;
}
.growth-review-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}
.growth-filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}
.growth-filter-label {
  font-weight: 600;
  color: #374151;
  font-size: 0.8rem;
  margin-right: 0.15rem;
}
.growth-filter-btn.active {
  background: #206bc4;
  color: #fff;
  border-color: #206bc4;
}
.growth-filter-select {
  width: auto;
  min-width: 100px;
  font-size: 0.8rem;
}
.growth-filter-input {
  width: 140px;
  font-size: 0.8rem;
}
.growth-review-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--tb-border);
  border-radius: 4px;
}
.growth-review-table {
  width: 100%;
  min-width: 780px;
  font-size: 0.8125rem;
}
.growth-review-table th,
.growth-review-table td {
  padding: 0.35rem 0.55rem;
  white-space: nowrap;
  height: 32px;
}
.growth-derived-badge {
  display: inline-block;
  padding: 0 4px;
  margin-left: 3px;
  background: #eef6ff;
  border: 1px solid #b9d3f3;
  border-radius: 3px;
  color: #1769c2;
  font-size: 0.68rem;
  font-weight: 600;
  vertical-align: middle;
  line-height: 1.4;
}
.growth-shape-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}
.growth-shape-stable {
  background: #eff6ff;
  color: #2563eb;
}
.growth-shape-stall {
  background: #f3f4f6;
  color: #6b7280;
}
.growth-shape-decline {
  background: #f5f3ff;
  color: #7c3aed;
}
.growth-shape-jump {
  background: #fff7ed;
  color: #ea580c;
}
.growth-shape-zero-base {
  background: #f9fafb;
  color: #9ca3af;
  border: 1px dashed #d1d5db;
}
.growth-shape-na {
  background: #f9fafb;
  color: #9ca3af;
  font-style: italic;
  border: 1px dashed #d1d5db;
}

/* ========== v2.0 等级成长审查 — 模式切换与单位选择 ========== */
.growth-mode-switcher {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
.growth-mode-label {
  font-weight: 600;
  color: #374151;
  font-size: 0.85rem;
  margin-right: 0.25rem;
}
.growth-mode-btn.active {
  background: #206bc4;
  color: #fff;
  border-color: #206bc4;
}

/* 单位选择工具栏 */
.growth-unit-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.growth-unit-toolbar select {
  min-width: 160px;
}
.growth-unit-nav {
  display: flex;
  gap: 0.35rem;
}
.growth-unit-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}
.growth-unit-meta strong {
  color: #1f2937;
}
.growth-unit-meta .badge {
  font-size: 0.75rem;
}

/* 异常单位折叠 */
.growth-issues-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.growth-issue-unit {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}
.growth-issue-unit.expanded {
  border-color: #206bc4;
}
.growth-issue-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  background: #f8fafc;
  user-select: none;
}
.growth-issue-header:hover {
  background: #f1f5f9;
}
.growth-issue-header strong {
  font-size: 0.9rem;
  color: #1f2937;
}
.growth-issue-header .badge {
  font-size: 0.7rem;
}
.growth-issue-body {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid #e5e7eb;
}

/* 分页 */
.growth-pagination {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* ========== v1.0 同费比较 ========== */
.cost-peer-root {
  background: #fff;
  border: 1px solid var(--tb-border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
}
.cost-peer-title {
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
  margin: 0 0 0.25rem 0;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid #206bc4;
}
.cost-peer-desc {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}
.cost-peer-filters {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}
.cost-peer-filter-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}
.cost-peer-filter-label {
  font-weight: 600;
  color: #374151;
  font-size: 0.8rem;
  margin-right: 0.15rem;
}
.cost-peer-level-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.cost-peer-mode-select,
.cost-peer-cost-select,
.cost-peer-metric-select {
  width: auto;
  min-width: 80px;
  font-size: 0.8rem;
}
.cost-peer-group {
  background: #fafbfc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}
.cost-peer-group-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.cost-peer-group-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #206bc4;
}
.cost-peer-group-count {
  font-size: 0.8rem;
  color: #6b7280;
}
.cost-peer-single-hint {
  font-size: 0.78rem;
  color: #ea580c;
  font-weight: 500;
}
.cost-peer-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: #374151;
}
.cost-peer-stat {
  white-space: nowrap;
}
.cost-peer-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--tb-border);
  border-radius: 4px;
}
.cost-peer-table {
  width: 100%;
  min-width: 560px;
  font-size: 0.8125rem;
}
.cost-peer-table th,
.cost-peer-table td {
  padding: 0.35rem 0.55rem;
  white-space: nowrap;
  height: 32px;
}
.cost-peer-empty {
  padding: 1rem 0.5rem;
  text-align: center;
  color: var(--tb-muted);
  font-size: 0.875rem;
}

/* ========== v1.0 tooltip 优化（支持多行） ========== */
.modified-cell[title] {
  cursor: help;
}

/* 数字列统一右对齐 + 等宽数字 */
.native-table td.text-right,
.cost-peer-table td.text-right,
.growth-review-table td.text-right,
.change-review-table td.text-right {
  font-variant-numeric: tabular-nums;
}

/* ========== v1.1 AI Panel ========== */
#tab-ai .ai-subtab-nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--tb-border);
  margin-bottom: 0.75rem;
}
.ai-subtab-btn {
  background: #fff;
  border: 1px solid var(--tb-border);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  color: #6b7280;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.ai-subtab-btn.active {
  color: #206bc4;
  border-color: #206bc4;
  border-bottom: 1px solid #fff;
  margin-bottom: -1px;
  font-weight: 600;
}
.ai-subtab-btn:hover:not(.active) {
  color: #374151;
  border-color: #94a3b8;
}
.ai-status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding: 0.5rem 0.75rem !important;
}
#tab-ai .ai-status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 10px;
  border: 1px solid #d7dee8;
  border-radius: 6px;
  background: #eef2f7;
  color: #334155 !important;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  opacity: 1;
  visibility: visible;
  white-space: nowrap;
}
.ai-quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.ai-unit-select,
.ai-issue-select {
  width: auto;
  max-width: 200px;
  display: inline-block;
  font-size: 0.8rem;
}
#tab-ai .ai-message-list {
  max-height: 500px;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 0.75rem !important;
  background: #f9fafb;
}
.ai-empty {
  text-align: center;
  color: #9ca3af;
  padding: 2rem;
  font-size: 0.9rem;
}
.ai-msg {
  margin-bottom: 0.75rem;
}
.ai-msg-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 0.15rem;
}
.ai-msg-content {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
  line-height: 1.55;
}
.ai-msg-user .ai-msg-content {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: #1e3a5f;
}
.ai-msg-assistant .ai-msg-content {
  background: #fff;
  border: 1px solid var(--tb-border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: #1f2937;
}
.ai-msg-reasoning .ai-msg-content {
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: #92400e;
  font-size: 0.8rem;
}
.ai-msg-reasoning-inner {
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: #92400e;
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}
.ai-msg-error .ai-msg-content {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: #991b1b;
}
.ai-input-area {
  padding: 0.5rem 0.75rem !important;
}
.ai-input-textarea {
  font-size: 0.85rem;
  resize: vertical;
}
.ai-input-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.ai-key-row {
  display: flex;
  gap: 0.35rem;
}
.ai-key-input {
  flex: 1;
}
.ai-settings-form .form-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.15rem;
}
.ai-settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
#tab-ai .ai-wait-status {
  display: none;
  margin: 10px 0 14px;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-line;
}
#tab-ai .ai-wait-status.is-visible {
  display: block;
}

/* ========== v1.2 身份与克制分析 ========== */

/* 导入状态指标卡 */
.section-card .metric-box {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  text-align: center;
  min-width: 100px;
}
.section-card .metric-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #206bc4;
}
.section-card .metric-label {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 2px;
}

/* Chip 筛选组 */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #fff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover {
  border-color: #2563eb;
  color: #1e40af;
}
.chip.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

/* 设计档案卡片网格 */
.design-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}
.design-profile-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.design-profile-card:hover {
  border-color: #2563eb;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.1);
}
.design-profile-card.unmatched {
  border-left: 3px solid #ea580c;
  opacity: 0.85;
}
.design-profile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}
.design-profile-name {
  font-weight: 700;
  color: #206bc4;
  font-size: 0.92rem;
}
.design-profile-category {
  font-size: 0.72rem;
  color: #6b7280;
  background: #f3f4f6;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}
.design-profile-summary {
  font-size: 0.78rem;
  color: #6b7280;
  line-height: 1.4;
  margin-bottom: 0.35rem;
}
.design-profile-stats {
  font-size: 0.72rem;
  color: #475569;
  font-variant-numeric: tabular-nums;
}

/* 状态徽章 */
.status-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

/* 数据表格（用于设计审查和克制关系） */
.data-table {
  width: 100%;
  min-width: 640px;
  font-size: 0.8125rem;
  border-collapse: collapse;
}
.data-table th,
.data-table td {
  padding: 0.4rem 0.6rem;
  border: 1px solid #e5e7eb;
  text-align: left;
}
.data-table th {
  background: #f8fafc;
  font-weight: 600;
  color: #374151;
  position: sticky;
  top: 0;
  z-index: 2;
}
.data-table tr:nth-child(even) {
  background: #fafbfc;
}
.data-table tr:hover {
  background: #f3f4f6;
}

/* 克制矩阵 */
.matrix-table {
  width: max-content;
  border-collapse: separate;
  border-spacing: 3px;
  font-size: 0.72rem;
}
.matrix-table th,
.matrix-table td {
  min-width: 68px;
  max-width: 68px;
  height: 42px;
  padding: 4px 2px;
  text-align: center;
  vertical-align: middle;
  border: 1px solid #e5e7eb;
  border-radius: 3px;
}
.matrix-table thead th {
  background: #f8fafc;
  font-weight: 600;
  color: #374151;
  position: sticky;
  top: 0;
  z-index: 3;
  font-size: 0.7rem;
}
.matrix-table tbody th {
  background: #f8fafc;
  font-weight: 600;
  color: #374151;
  position: sticky;
  left: 0;
  z-index: 2;
  font-size: 0.72rem;
}
.matrix-table thead th:first-child {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 4;
  background: #f8fafc;
}

/* 模态框 */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1050;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  padding: 1.25rem;
  max-width: 700px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

/* 网格布局 */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}
@media (max-width: 768px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .design-profile-grid {
    grid-template-columns: 1fr;
  }
}
