﻿:root {
  --bg: #0b1020;
  --panel: #121a2b;
  --card: #121a2b;
  --card-hover: #162038;
  --line: #22304d;
  --line-soft: #1e2a45;
  --text: #d9e3f5;
  --muted: #8ea0c2;
  --up: #19c37d;
  --down: #ff5c7a;
  --warn: #ffb020;
  --wait: #5b7cfa;
  --info: #4cc2ff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.15);
  --shadow-hover: 0 8px 28px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.2);
  --transition: 180ms ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 14px/1.45 system-ui, Segoe UI, Arial;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(11, 16, 32, 0.92);
  backdrop-filter: blur(4px);
  z-index: 100;
}

h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text) 0%, var(--info) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: #c8d6f2;
  display: flex;
  align-items: center;
  gap: 8px;
}

h2::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--info), var(--up));
}

.meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.pill {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0f1730;
  transition: all var(--transition);
}

.pill:hover {
  border-color: var(--line-soft);
  background: #131d3a;
}

.pill.warn {
  color: #1a1200;
  background: var(--warn);
  border-color: var(--warn);
  font-weight: 600;
  box-shadow: 0 0 12px rgba(255, 176, 32, 0.3);
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(76, 194, 255, 0.3), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}

.card:hover {
  border-color: var(--line-soft);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card:hover::before {
  opacity: 1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #c8d6f2;
}

.card-subtitle {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.card-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}

.card-badge.up {
  color: var(--up);
  background: rgba(25, 195, 125, 0.12);
  border-color: rgba(25, 195, 125, 0.3);
}

.card-badge.down {
  color: var(--down);
  background: rgba(255, 92, 122, 0.12);
  border-color: rgba(255, 92, 122, 0.3);
}

.card-badge.warn {
  color: var(--warn);
  background: rgba(255, 176, 32, 0.12);
  border-color: rgba(255, 176, 32, 0.3);
}

.card-badge.info {
  color: var(--info);
  background: rgba(76, 194, 255, 0.12);
  border-color: rgba(76, 194, 255, 0.3);
}

.card-badge.neutral {
  color: var(--muted);
  background: rgba(142, 160, 194, 0.12);
  border-color: rgba(142, 160, 194, 0.3);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}

.status-dot.waiting {
  color: var(--wait);
}

.status-dot.observe {
  color: var(--warn);
}

.status-dot.confirmed {
  color: var(--up);
}

.status-dot.void {
  color: var(--down);
}

.status-dot.completed {
  color: var(--muted);
}

.status-dot.paused {
  color: var(--warn);
}

.card.hero {
  text-align: center;
  padding: 24px;
  background: linear-gradient(145deg, var(--card) 0%, #151f38 100%);
  border: 1px solid var(--line);
}

.card.hero::before {
  height: 2px;
  background: linear-gradient(90deg, var(--up), var(--info), var(--warn));
  opacity: 1;
}

.card.hero .state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 28px;
  border-radius: 999px;
  font-size: 24px;
  font-weight: 700;
  border: 1px solid var(--line);
  margin-bottom: 10px;
  min-width: 200px;
}

.card.hero .dir {
  font-size: 20px;
  font-weight: 700;
  margin: 8px 0;
}

.card.hero .reason {
  color: var(--muted);
  min-height: 24px;
  font-size: 14px;
}

.card.hero .subrow {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  margin: 14px 0;
}

.card.hero .subrow span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card.hero .subrow b {
  color: var(--text);
  font-weight: 600;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

@media (max-width: 900px) {
  .grid-2,
  .grid-4 {
    grid-template-columns: 1fr;
  }
  .grid-auto {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

@media (max-width: 600px) {
  .grid-auto {
    grid-template-columns: 1fr;
  }
}

.table-wrap {
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
}

table.kv,
table.bt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.kv td,
table.bt-table th,
table.bt-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
}

table.kv td:first-child {
  color: var(--muted);
  width: 46%;
  font-weight: 500;
}

table.kv td:last-child,
table.bt-table td.num,
table.bt-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

table.bt-table th {
  position: sticky;
  top: 0;
  background: #141e36;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  z-index: 1;
  border-bottom: 2px solid var(--line);
}

table.bt-table tbody tr {
  transition: background var(--transition);
}

table.bt-table tbody tr:hover {
  background: rgba(76, 194, 255, 0.04);
}

table.bt-table td.up {
  color: var(--up);
}

table.bt-table td.down {
  color: var(--down);
}

table.bt-table td.pnl-up {
  color: var(--up);
}

table.bt-table td.pnl-down {
  color: var(--down);
}

.breadth-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 8px 0;
}

.breadth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.breadth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.breadth-card.up::before {
  background: var(--up);
}

.breadth-card.down::before {
  background: var(--down);
}

.breadth-card.flat::before {
  background: var(--info);
}

.breadth-card.unk::before {
  background: var(--muted);
}

.breadth-card:hover {
  border-color: var(--line-soft);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.breadth-card .n {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.breadth-card.up .n {
  color: var(--up);
}

.breadth-card.down .n {
  color: var(--down);
}

.breadth-card.flat .n {
  color: var(--info);
}

.breadth-card.unk .n {
  color: var(--muted);
}

.breadth-card .l {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}

.breadth-note {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.breadth-note span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadth-note b {
  color: var(--text);
  font-weight: 600;
}

.checks-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #0f1730;
  font-size: 13px;
  transition: all var(--transition);
}

.check-card:hover {
  border-color: var(--line-soft);
  background: #131d3a;
  transform: translateX(2px);
}

.check-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex: 0 0 22px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.check-mark.ok {
  background: rgba(25, 195, 125, 0.18);
  color: var(--up);
  border: 1px solid rgba(25, 195, 125, 0.3);
}

.check-mark.no {
  background: rgba(255, 92, 122, 0.15);
  color: var(--down);
  border: 1px solid rgba(255, 92, 122, 0.3);
}

.check-content {
  flex: 1;
  min-width: 0;
}

.check-name {
  font-weight: 500;
  color: var(--text);
}

.check-detail {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  line-height: 1.4;
}

.history-list {
  max-height: 280px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}

.history-card {
  padding: 10px 12px;
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm);
  background: #0f1730;
  color: #c8d6f2;
  transition: all var(--transition);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.history-card:hover {
  background: #131d3a;
  border-left-color: var(--up);
  transform: translateX(2px);
}

.history-time {
  color: var(--muted);
  margin-right: 8px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.history-kind {
  font-weight: 600;
  color: var(--info);
}

.history-direction.up {
  color: var(--up);
}

.history-direction.down {
  color: var(--down);
}

.history-reason {
  color: var(--muted);
  flex: 1;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--info);
}

.stat-card.up::before {
  background: var(--up);
}

.stat-card.down::before {
  background: var(--down);
}

.stat-card.warn::before {
  background: var(--warn);
}

.stat-card:hover {
  border-color: var(--line-soft);
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.stat-card .lab {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.stat-card .val {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
  line-height: 1.2;
}

.stat-card .val.up {
  color: var(--up);
}

.stat-card .val.down {
  color: var(--down);
}

.stat-card .val.warn {
  color: var(--warn);
}

.chart-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.chart-head h2 {
  margin: 0;
}

.legend-note {
  color: var(--muted);
  font-size: 12px;
}

.kchart,
.bt-chart-k,
.bt-chart-eq {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #0a1122;
}

.kchart {
  height: 420px;
}

.bt-chart-k {
  height: 420px;
}

.bt-chart-eq {
  height: 220px;
}

.chart-info {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  padding: 10px 12px;
  background: #0f1730;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
}

.chart-info b {
  color: var(--text);
  font-weight: 600;
}

.chart-info .up {
  color: var(--up);
}

.chart-info .down {
  color: var(--down);
}

.chart-info .warn {
  color: var(--warn);
}

#sharedDashboard {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#liveChartPanel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#liveChartPanel[hidden] {
  display: none;
}

#backtestPanel {
  display: flex;
  flex-direction: column;
  gap: 16px;
 }

#backtestPanel[hidden] {
  display: none;
}

.seg-control {
  display: inline-flex;
  background: #0f1730;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 20px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn.active {
  background: #1b2744;
  color: var(--text);
  box-shadow: inset 0 0 0 1px #31456f;
}

.bt-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 4px 0;
}

.bt-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.bt-field label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bt-field input[type="date"],
.bt-field input[type="number"] {
  background: #0f1730;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  transition: all var(--transition);
}

.bt-field input[type="date"]:focus,
.bt-field input[type="number"]:focus {
  outline: none;
  border-color: var(--wait);
  box-shadow: 0 0 0 3px rgba(91, 124, 250, 0.15);
}

.bt-field input[type="range"] {
  width: 180px;
  accent-color: var(--wait);
}

.bt-field.bt-seek input[type="range"] {
  width: 280px;
  accent-color: var(--warn);
}

.bt-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  font-size: 12px;
}

.bt-progress-meta {
  color: var(--muted);
}

.bt-progress-meta b {
  color: var(--text);
}

.bt-download-meta {
  color: var(--muted);
}

.bt-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .bt-charts {
    grid-template-columns: 1fr;
  }
}

button {
  background: #1b2744;
  color: var(--text);
  border: 1px solid #31456f;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}

button:hover:not(:disabled) {
  background: #223155;
  border-color: #3a4d7a;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button.primary {
  background: #0b3b26;
  border-color: #1d7a4e;
}

button.primary:hover:not(:disabled) {
  background: #0f4d2f;
  border-color: #2a9a5f;
}

button.danger {
  background: #3a121a;
  border-color: #7a2b39;
}

button.danger:hover:not(:disabled) {
  background: #4d1822;
  border-color: #9a3548;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

.notes {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.notes li {
  margin: 4px 0;
}

.errors {
  color: #ff9fb2;
  font-size: 12px;
  white-space: pre-wrap;
  margin-top: 12px;
  padding: 12px;
  background: rgba(255, 92, 122, 0.08);
  border: 1px solid rgba(255, 92, 122, 0.2);
  border-radius: var(--radius-sm);
}

code {
  background: #0f1730;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  font-size: 12px;
}

.lifecycle {
  color: #ffd27a;
  font-size: 13px;
  min-height: 20px;
  font-weight: 500;
}

.risk-plan {
  margin-top: 12px;
  padding: 12px;
  background: rgba(255, 176, 32, 0.08);
  border: 1px solid rgba(255, 176, 32, 0.2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
}

.risk-plan b {
  color: var(--warn);
}

.choppy-alert {
  padding: 10px 14px;
  background: rgba(255, 92, 122, 0.12);
  border: 1px solid rgba(255, 92, 122, 0.3);
  border-radius: var(--radius-sm);
  color: var(--down);
  font-weight: 600;
  font-size: 13px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.eod-badge {
  padding: 8px 12px;
  background: rgba(91, 124, 250, 0.1);
  border: 1px solid rgba(91, 124, 250, 0.3);
  border-radius: var(--radius-sm);
  color: var(--wait);
  font-weight: 600;
  font-size: 12px;
  margin-top: 8px;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--line-soft);
}

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

.card {
  animation: fadeIn 300ms ease forwards;
}

.state.WAITING,
.state.等待 {
  background: #18224a;
  color: #cfe0ff;
  border-color: #2a3d6b;
}

.state.OBSERVE_CONFIRM,
.state.观望确认中 {
  background: #332600;
  color: #ffd27a;
  border-color: #7a5a00;
}

.state.CONFIRMED,
.state.有效讯号 {
  background: #06331f;
  color: #7dffbf;
  border-color: #1d7a4e;
}

.state.VOID,
.state.讯号作废 {
  background: #3a121a;
  color: #ff9fb2;
  border-color: #7a2b39;
}

.state.COMPLETED,
.state.已完结 {
  background: #1f2438;
  color: #aebce0;
  border-color: #354a6e;
}

.state.PAUSED,
.state.风险暂停 {
  background: #3a2a06;
  color: #ffd27a;
  border-color: #8a6400;
}

*:focus-visible {
  outline: 2px solid var(--wait);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
