/* backtest.css — 回测页面专用样式 */
.bt-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  padding: 16px;
  min-height: calc(100vh - 60px);
}

.bt-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  max-height: calc(100vh - 76px);
}

.bt-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bt-chart {
  width: 100%;
  height: 400px;
  background: white;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.bt-equity-chart {
  height: 250px;
}

.bt-select {
  padding: 6px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  background: white;
  color: #334155;
}

.bt-input {
  padding: 6px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  width: 120px;
  background: white;
  color: #334155;
}

.bt-run-btn {
  padding: 6px 20px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.bt-run-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.bt-run-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.bt-run-btn.running {
  background: linear-gradient(135deg, #f59e0b, #f97316);
}

/* Panel */
.bt-panel {
  background: white;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  padding: 16px;
}

.bt-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 12px;
}

.bt-available {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.bt-strategy-btn {
  padding: 4px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 12px;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}

.bt-strategy-btn:hover {
  background: #e0f2fe;
  border-color: #7dd3fc;
}

.bt-strategy-btn.active {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.bt-reits-btn {
  border-color: #a78bfa;
  color: #7c3aed;
}

.bt-reits-btn:hover {
  background: #ede9fe;
  border-color: #a78bfa;
}

.bt-reits-btn.active {
  background: #7c3aed;
  color: white;
  border-color: #7c3aed;
}

.bt-strategy-group-label {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  margin-top: 8px;
}

.bt-slots {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bt-empty {
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
  padding: 12px;
}

.bt-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
  transition: all 0.15s;
}

.bt-slot.disabled {
  opacity: 0.4;
}

.bt-slot:hover {
  border-color: #94a3b8;
}

.bt-slot-drag-handle {
  cursor: grab;
  color: #94a3b8;
  font-size: 16px;
}

.bt-slot-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #334155;
  cursor: pointer;
  min-width: 80px;
}

.bt-slot-weight {
  flex: 1;
  height: 4px;
}

.bt-slot-weight-val {
  font-size: 11px;
  color: #64748b;
  min-width: 35px;
  text-align: right;
}

.bt-slot-remove {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bt-slot-remove:hover {
  background: #fee2e2;
  color: #ef4444;
}

.bt-slot-params {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  width: 100%;
}

.bt-slot-param-label {
  font-size: 10px;
  color: #64748b;
  min-width: 30px;
}

.bt-slot-param {
  width: 50px;
  padding: 2px 4px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 11px;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
}

.bt-slot-param:focus {
  outline: none;
  border-color: #3b82f6;
}

/* Quotes panel */
.bt-quotes-panel {
  background: white;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  padding: 16px;
}

.bt-quotes-title {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 12px;
}

.bt-quotes-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bt-quotes-code {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.bt-quotes-price {
  font-size: 24px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.bt-quotes-price.up { color: #dc2626; }
.bt-quotes-price.down { color: #16a34a; }

.bt-quotes-change {
  font-size: 14px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
}

.bt-quotes-change.up { color: #dc2626; }
.bt-quotes-change.down { color: #16a34a; }

.bt-quotes-vol {
  font-size: 12px;
  color: #64748b;
}

.bt-quotes-empty {
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
  padding: 8px;
}

/* Metrics card */
.bt-metrics-card {
  background: white;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  padding: 16px;
}

.bt-metrics-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 12px;
}

.bt-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.bt-metric {
  display: flex;
  flex-direction: column;
  padding: 8px;
  background: #f8fafc;
  border-radius: 6px;
}

.bt-metric-label {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 2px;
}

.bt-metric-value {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  font-family: 'JetBrains Mono', monospace;
}

/* Trade log card */
.bt-trade-log-card {
  background: white;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  padding: 16px;
}

.bt-trade-log-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 12px;
}

.bt-trade-count {
  font-size: 12px;
  font-weight: 400;
  color: #64748b;
}

.bt-trade-log-body {
  max-height: 300px;
  overflow-y: auto;
}

.bt-trade-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.bt-trade-table th {
  text-align: left;
  padding: 6px 4px;
  border-bottom: 1px solid #e2e8f0;
  color: #64748b;
  font-weight: 500;
  font-size: 10px;
  white-space: nowrap;
}

.bt-trade-table td {
  padding: 5px 4px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  white-space: nowrap;
}

.bt-trade-table tr.bt-trade-win td {
  color: #16a34a;
}

.bt-trade-table tr.bt-trade-loss td {
  color: #dc2626;
}

.bt-trade-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
}

.bt-trade-badge.bt-trade-win {
  background: #dcfce7;
  color: #16a34a;
}

.bt-trade-badge.bt-trade-loss {
  background: #fee2e2;
  color: #dc2626;
}

/* Status bar */
.bt-status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1e293b;
  color: white;
  padding: 8px 16px;
  font-size: 13px;
  z-index: 100;
}

.bt-heatmap-chart {
  height: 300px;
}

.bt-heatmap-section {
  background: white;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  padding: 16px;
}

.bt-heatmap-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 12px;
}

.bt-optimal-params {
  font-size: 12px;
  font-weight: 400;
  color: #64748b;
}

.bt-compare-section {
  background: white;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  padding: 16px;
}

.bt-compare-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 12px;
}

.bt-compare-count {
  font-size: 12px;
  font-weight: 400;
  color: #64748b;
}

.bt-compare-table-wrap {
  overflow-x: auto;
}

.bt-compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.bt-compare-table th {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 2px solid #e2e8f0;
  color: #64748b;
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
}

.bt-compare-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.bt-compare-table tr.bt-compare-best td {
  background: #f0fdf4;
  font-weight: 600;
}

.bt-compare-table .bt-compare-strategy-name {
  font-weight: 600;
  color: #1e293b;
  font-family: 'Inter', sans-serif;
}

@media (max-width: 768px) {
  .bt-layout {
    grid-template-columns: 1fr;
    padding: 8px;
    gap: 8px;
  }
  .bt-sidebar {
    max-height: none;
    order: 1;
  }
  .bt-main {
    order: 0;
  }
  .bt-chart {
    height: 280px;
  }
  .bt-equity-chart {
    height: 180px;
  }
  .bt-heatmap-chart {
    height: 220px;
  }
  .bt-metrics-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .bt-trade-log-body {
    max-height: 200px;
  }
  .bt-trade-table {
    font-size: 10px;
  }
  .bt-run-btn {
    padding: 6px 12px;
    font-size: 12px;
  }
  .bt-select, .bt-input {
    font-size: 12px;
    padding: 4px 6px;
  }
  .bt-status-bar {
    font-size: 11px;
    padding: 6px 8px;
    bottom: 56px;
  }
}

@media (max-width: 480px) {
  .bt-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .bt-chart {
    height: 220px;
  }
  .bt-equity-chart {
    height: 150px;
  }
  .bt-panel {
    padding: 10px;
  }
  .bt-metric-value {
    font-size: 14px;
  }
}

[data-theme="dark"],
@media (prefers-color-scheme: dark) {
  .bt-chart {
    background: #1e293b;
    border-color: #334155;
  }
  .bt-select, .bt-input {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #475569;
  }
  .bt-panel {
    background: #1e293b;
    border-color: #334155;
  }
  .bt-panel-title {
    color: #e2e8f0;
  }
  .bt-strategy-btn {
    background: #334155;
    color: #cbd5e1;
    border-color: #475569;
  }
  .bt-strategy-btn:hover {
    background: #475569;
    border-color: #64748b;
  }
  .bt-strategy-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
  }
  .bt-reits-btn {
    border-color: #7c3aed;
    color: #a78bfa;
  }
  .bt-reits-btn:hover {
    background: #4c1d95;
    border-color: #7c3aed;
  }
  .bt-reits-btn.active {
    background: #7c3aed;
    color: white;
  }
  .bt-slot {
    background: #334155;
    border-color: #475569;
  }
  .bt-slot:hover {
    border-color: #64748b;
  }
  .bt-slot-toggle {
    color: #e2e8f0;
  }
  .bt-slot-weight-val {
    color: #94a3b8;
  }
  .bt-slot-param {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #475569;
  }
  .bt-slot-param:focus {
    border-color: #3b82f6;
  }
  .bt-metrics-card {
    background: #1e293b;
    border-color: #334155;
  }
  .bt-metrics-card h3 {
    color: #e2e8f0;
  }
  .bt-metric {
    background: #334155;
  }
  .bt-metric-label {
    color: #94a3b8;
  }
  .bt-metric-value {
    color: #e2e8f0;
  }
  .bt-trade-log-card {
    background: #1e293b;
    border-color: #334155;
  }
  .bt-trade-log-card h3 {
    color: #e2e8f0;
  }
  .bt-trade-count {
    color: #94a3b8;
  }
  .bt-trade-table th {
    border-bottom-color: #475569;
    color: #94a3b8;
  }
  .bt-trade-table td {
    border-bottom-color: #334155;
    color: #cbd5e1;
  }
  .bt-trade-badge.bt-trade-win {
    background: #064e3b;
    color: #34d399;
  }
  .bt-trade-badge.bt-trade-loss {
    background: #7f1d1d;
    color: #f87171;
  }
  .bt-trade-table tr.bt-trade-win td {
    color: #34d399;
  }
  .bt-trade-table tr.bt-trade-loss td {
    color: #f87171;
  }
  .bt-quotes-panel {
    background: #1e293b;
    border-color: #334155;
  }
  .bt-quotes-title {
    color: #e2e8f0;
  }
  .bt-quotes-code {
    color: #e2e8f0;
  }
  .bt-quotes-vol {
    color: #94a3b8;
  }
  .bt-heatmap-section {
    background: #1e293b;
    border-color: #334155;
  }
  .bt-heatmap-section h3 {
    color: #e2e8f0;
  }
  .bt-optimal-params {
    color: #94a3b8;
  }
  .bt-compare-section {
    background: #1e293b;
    border-color: #334155;
  }
  .bt-compare-section h3 {
    color: #e2e8f0;
  }
  .bt-compare-count {
    color: #94a3b8;
  }
  .bt-compare-table th {
    border-bottom-color: #475569;
    color: #94a3b8;
  }
  .bt-compare-table td {
    border-bottom-color: #334155;
    color: #cbd5e1;
  }
  .bt-compare-table tr.bt-compare-best td {
    background: #064e3b;
  }
  .bt-compare-table .bt-compare-strategy-name {
    color: #e2e8f0;
  }
  .bt-status-bar {
    background: #0f172a;
  }
  .bt-strategy-group-label {
    color: #64748b;
  }
  .bt-empty {
    color: #64748b;
  }
}

[data-theme="dark"] .bt-run-btn,
@media (prefers-color-scheme: dark) .bt-run-btn {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
}
[data-theme="dark"] .bt-run-btn.running,
@media (prefers-color-scheme: dark) .bt-run-btn.running {
  background: linear-gradient(135deg, #f59e0b, #f97316);
}
