:root {
  --bg-main: #0b0f17;
  --bg-card: #121824;
  --bg-card-sub: #172131;
  --border-color: #223047;
  --border-bright: #334460;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-fine: #64748b;
  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.15);
  --green-glow: rgba(16, 185, 129, 0.35);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.15);
  --red-glow: rgba(239, 68, 68, 0.35);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.15);
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.15);
  --purple: #8b5cf6;
  --purple-bg: rgba(139, 92, 246, 0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg-main);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  padding: 0 0 50px 0;
  -webkit-font-smoothing: antialiased;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background: #0d131f;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left .eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--blue);
  font-weight: 600;
  margin-bottom: 2px;
}
header h1 {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
#clock {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
}
button {
  background: var(--bg-card-sub);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
}
button:hover { background: var(--border-color); }
button.primary {
  background: #2563eb;
  border-color: #3b82f6;
  color: #fff;
}
button.primary:hover { background: #1d4ed8; }

main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 实时行情条 (Hero Ticker Bar) */
.realtime-bar {
  background: linear-gradient(90deg, #101726 0%, #151e30 100%);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.hero-left {
  display: flex;
  align-items: center;
  gap: 20px;
}
.hero-symbol {
  display: flex;
  flex-direction: column;
}
.hero-sym-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.hero-sym-source {
  font-size: 12px;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 5px;
}
.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--green);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.hero-price-box {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 4px 12px;
  border-radius: 8px;
  transition: background-color 0.4s ease;
}
.hero-price-val {
  font-size: 32px;
  font-weight: 800;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: -0.02em;
}
.hero-change-badge {
  font-size: 14px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.hero-stats {
  display: flex;
  gap: 24px;
}
.hero-stat {
  display: flex;
  flex-direction: column;
}
.hero-stat .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.hero-stat .val {
  font-size: 15px;
  font-weight: 600;
  font-family: ui-monospace, monospace;
}

/* 闪烁动效 */
.flash-up {
  animation: flash-green-anim 0.8s ease-out;
}
.flash-down {
  animation: flash-red-anim 0.8s ease-out;
}
@keyframes flash-green-anim {
  0% { background-color: var(--green-glow); color: #fff; }
  100% { background-color: transparent; }
}
@keyframes flash-red-anim {
  0% { background-color: var(--red-glow); color: #fff; }
  100% { background-color: transparent; }
}

/* 顶部状态网格 */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.metric-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric-box .label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.metric-box strong {
  font-size: 22px;
  font-weight: 700;
}
.metric-box small {
  font-size: 12px;
  color: var(--text-fine);
}

/* 板块通用 */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.section-head h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}
.help-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

/* 多周期卡片 */
.timeframe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.tf-card {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.15s ease, border-color 0.15s ease;
  position: relative;
  overflow: hidden;
}
.tf-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-bright);
}
.tf-card.active-signal {
  border-color: var(--green);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.25);
}
.tf-card.active-signal-put {
  border-color: var(--red);
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.25);
}

.tf-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tf-title {
  font-size: 15px;
  font-weight: 700;
}
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.purple { background: var(--purple-bg); color: var(--purple); }

.tf-price-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 10px;
  background: rgba(0,0,0,0.25);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.04);
}
.tf-live-price {
  font-size: 22px;
  font-weight: 800;
  font-family: ui-monospace, monospace;
}
.tf-floating-pct {
  font-size: 13px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
}

.tf-countdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 4px 6px;
  background: rgba(255,255,255,0.03);
  border-radius: 4px;
}
.tf-countdown-val {
  font-family: ui-monospace, monospace;
  font-weight: 700;
  color: var(--blue);
}

.tf-status-desc {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
}
.tf-metrics {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
}
.tf-row {
  display: flex;
  justify-content: space-between;
  color: var(--text-main);
}
.tf-row .muted { color: var(--text-muted); }

/* 策略引擎架构面板 */
.strategy-box {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px 18px;
  margin-top: 10px;
}
.strat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.strat-item:last-child { border-bottom: none; }
.strat-info { display: flex; flex-direction: column; gap: 2px; }
.strat-name { font-weight: 600; font-size: 14px; }
.strat-desc { font-size: 12px; color: var(--text-muted); }

/* 回测概览 4 大 KPI */
.backtest-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--bg-card-sub);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kpi-card .kpi-label { font-size: 12px; color: var(--text-muted); }
.kpi-card .kpi-val { font-size: 24px; font-weight: 800; font-family: ui-monospace, monospace; }
.kpi-card .kpi-sub { font-size: 12px; color: var(--text-fine); }

/* 表格通用 */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}
.table-scroll::-webkit-scrollbar {
  height: 6px;
}
.table-scroll::-webkit-scrollbar-track {
  background: var(--bg-card);
}
.table-scroll::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
.table-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--border-bright);
}
details summary {
  cursor: pointer;
  padding: 4px 0;
  user-select: none;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}
th {
  background: var(--bg-card-sub);
  color: var(--text-muted);
  font-weight: 600;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-main);
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

.price-cell {
  font-family: ui-monospace, monospace;
  font-weight: 700;
}
.date-cell {
  font-family: ui-monospace, monospace;
  color: var(--text-muted);
}
.rationale-cell {
  max-width: 320px;
  white-space: normal;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* 颜色辅助 */
.green { color: var(--green); }
.red { color: var(--red); }
.amber { color: var(--amber); }
.blue { color: var(--blue); }
.purple { color: var(--purple); }
.muted { color: var(--text-muted); }
.fine { color: var(--text-fine); font-size: 11px; }

/* 两栏响应式 */
.two-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}
@media (max-width: 1080px) {
  .two-col { grid-template-columns: 1fr; }
}

/* 测试工具行 */
.test-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
select {
  background: var(--bg-card-sub);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  outline: none;
}
select:focus { border-color: var(--blue); }

dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  row-gap: 8px;
  font-size: 13px;
  margin-top: 10px;
}
dt { color: var(--text-muted); }
dd { color: var(--text-main); font-weight: 500; }

footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-fine);
  padding: 20px 0;
}
.hidden { display: none !important; }
.error-bar {
  background: var(--red-bg);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
}

/* ==================== 登录页面精致设计 ==================== */
body.login-page {
  background: radial-gradient(circle at 50% 20%, #152238 0%, #0a0e17 80%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-wrapper {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
}
.login-brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  color: #60a5fa;
  letter-spacing: 0.08em;
}
.brand-dot {
  width: 6px;
  height: 6px;
  background: #3b82f6;
  border-radius: 50%;
  box-shadow: 0 0 6px #3b82f6;
}
.login-brand h1 {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
}
.brand-sub {
  font-size: 13px;
  color: var(--text-muted);
}
.login-card {
  width: 100%;
  background: rgba(18, 24, 36, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(51, 68, 96, 0.6);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 1px rgba(59, 130, 246, 0.5);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.card-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: #f8fafc;
}
.security-tag {
  font-size: 11px;
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-weight: 600;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.input-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.input-box {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute;
  left: 12px;
  color: #64748b;
  pointer-events: none;
}
.input-box input {
  width: 100%;
  background: #0f1623;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px 10px 36px;
  font-size: 14px;
  color: #fff;
  outline: none;
  transition: all 0.2s ease;
}
.input-box input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  background: #131d2e;
}
.input-box input::placeholder {
  color: #475569;
}
.login-btn {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  border: 1px solid #3b82f6;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transition: all 0.2s ease;
  margin-top: 6px;
}
.login-btn:hover {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}
.login-btn:active {
  transform: translateY(0);
}
.card-footer {
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.footer-tip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-fine);
  line-height: 1.4;
}
.login-copyright {
  font-size: 11px;
  color: #475569;
  text-align: center;
}
.login-card .error {
  background: var(--red-bg);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}

/* ==================== 移动端与不同屏幕深度适配 ==================== */
@media (max-width: 860px) {
  .two-col {
    grid-template-columns: 1fr;
  }
  main {
    padding: 16px 16px;
    gap: 16px;
  }
  .header-left .eyebrow {
    font-size: 11px;
  }
  header h1 {
    font-size: 18px;
  }
  .timeframe-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }
}

@media (max-width: 640px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 14px;
    gap: 10px;
  }
  .header-right {
    width: 100%;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 8px;
  }
  header h1 {
    font-size: 17px;
    flex-wrap: wrap;
  }
  main {
    padding: 10px 10px;
    gap: 12px;
  }
  .realtime-bar {
    padding: 14px 14px;
    border-radius: 10px;
    gap: 12px;
  }
  .hero-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
  }
  .hero-price-box {
    padding: 0;
    width: 100%;
    justify-content: flex-start;
    gap: 10px;
  }
  .hero-price-val {
    font-size: 26px;
  }
  .hero-change-badge {
    font-size: 13px;
  }
  .hero-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
    width: 100%;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
  }
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .metric-box {
    padding: 10px 12px;
    border-radius: 8px;
    gap: 2px;
  }
  .metric-box .label {
    font-size: 11px;
  }
  .metric-box strong {
    font-size: 17px;
    word-break: break-all;
  }
  .metric-box small {
    font-size: 11px;
  }
  .panel {
    padding: 14px 12px;
    border-radius: 10px;
  }
  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 8px;
  }
  .section-head h2 {
    font-size: 16px;
  }
  .section-head div {
    flex-wrap: wrap;
    width: 100%;
  }
  .timeframe-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .tf-card {
    padding: 12px 14px;
  }
  .backtest-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
  }
  .kpi-card {
    padding: 10px 12px;
    gap: 2px;
  }
  .kpi-card .kpi-label {
    font-size: 11px;
  }
  .kpi-card .kpi-val {
    font-size: 20px;
  }
  .kpi-card .kpi-sub {
    font-size: 11px;
  }
  .test-row {
    flex-direction: column;
    gap: 8px;
  }
  .test-row label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    width: 100%;
  }
  select, button {
    width: 100%;
    min-height: 40px;
    font-size: 14px;
  }
  table th, table td {
    padding: 8px 10px;
    font-size: 12px;
  }
  .rationale-cell {
    max-width: 220px;
    font-size: 11px;
  }
  dl {
    grid-template-columns: 100px 1fr;
    font-size: 12px;
  }
  body.login-page {
    padding: 16px 12px;
  }
  .login-card {
    padding: 22px 16px;
    border-radius: 12px;
  }
  .login-brand h1 {
    font-size: 20px;
  }
  .login-btn {
    min-height: 44px;
  }
}

@media (max-width: 380px) {
  .metrics-grid, .backtest-kpi-grid {
    grid-template-columns: 1fr;
  }
  header h1 {
    font-size: 15px;
  }
  .hero-price-val {
    font-size: 22px;
  }
}
