:root {
  --bg: #f4f7fb;
  --panel: rgba(255, 255, 255, .88);
  --text: #0f172a;
  --muted: #64748b;
  --line: rgba(148, 163, 184, .24);
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;
  --shadow: 0 24px 60px rgba(15, 23, 42, .08);
  --radius: 24px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 10% 10%, rgba(37, 99, 235, .14), transparent 28%),
    radial-gradient(circle at 80% 0%, rgba(14, 165, 233, .14), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 280px;
  padding: 24px;
  color: #fff;
  background: linear-gradient(160deg, #0f172a 0%, #1e3a8a 52%, #2563eb 100%);
  overflow: hidden;
}
.sidebar::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -90px;
  bottom: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.brand { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 16px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.16);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
  font-weight: 800;
}
.brand strong { display: block; font-size: 18px; letter-spacing: -.02em; }
.brand span { display: block; color: rgba(255,255,255,.72); font-size: 12px; margin-top: 2px; }
.nav { display: grid; gap: 8px; margin-top: 36px; position: relative; z-index: 1; }
.nav a {
  color: rgba(255,255,255,.78); text-decoration: none;
  padding: 13px 14px; border-radius: 14px;
  font-size: 14px; transition: all .2s ease;
}
.nav a:hover, .nav a.active {
  color: #fff; background: rgba(255,255,255,.15); transform: translateX(3px);
}
.side-card {
  position: absolute; left: 24px; right: 24px; bottom: 24px; z-index: 1;
  padding: 18px; border-radius: 20px;
  background: rgba(255,255,255,.12);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
  backdrop-filter: blur(10px);
}
.side-card span { display: block; font-size: 12px; color: rgba(255,255,255,.68); }
.side-card strong { display: block; margin-top: 6px; font-size: 20px; }
.side-card p { margin: 10px 0 0; color: rgba(255,255,255,.72); font-size: 12px; line-height: 1.6; }

.main { flex: 1; padding: 28px; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  margin-bottom: 24px;
}
.eyebrow { margin: 0 0 6px; color: var(--primary); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; }
h1 { margin: 0; font-size: clamp(24px, 3vw, 38px); letter-spacing: -.05em; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  border: 0; border-radius: 14px; padding: 11px 16px;
  font-weight: 700; cursor: pointer; transition: all .18s ease;
  color: var(--text); background: #fff; box-shadow: 0 10px 24px rgba(15,23,42,.08);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(15,23,42,.12); }
.btn.primary { color: #fff; background: linear-gradient(135deg, var(--primary), #0ea5e9); }
.btn.ghost { background: rgba(255,255,255,.75); box-shadow: inset 0 0 0 1px var(--line); }
.btn.small { padding: 7px 10px; border-radius: 10px; font-size: 12px; }
.btn.danger { color: #fff; background: linear-gradient(135deg, #ef4444, #f97316); }

.page-section { display: none; }
.page-section.active { display: block; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.stat-card, .panel {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.66);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.stat-card { padding: 22px; border-radius: var(--radius); position: relative; overflow: hidden; }
.stat-card::after {
  content: ""; position: absolute; right: -40px; top: -40px;
  width: 120px; height: 120px; border-radius: 50%; background: rgba(37,99,235,.08);
}
.stat-card span { display: block; color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin-top: 10px; font-size: 28px; letter-spacing: -.04em; }
.stat-card small { display: block; margin-top: 8px; color: var(--muted); }
.stat-card.accent { background: linear-gradient(145deg, rgba(37,99,235,.95), rgba(14,165,233,.92)); color: #fff; }
.stat-card.accent span, .stat-card.accent small { color: rgba(255,255,255,.75); }
.stat-card.danger-soft::after { background: rgba(220, 38, 38, .08); }

.grid.two { display: grid; grid-template-columns: 1.35fr .85fr; gap: 18px; }
.panel { border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.panel.tall { min-height: 350px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panel h2 { margin: 0; font-size: 20px; letter-spacing: -.04em; }
.panel p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.pill { padding: 6px 10px; border-radius: 999px; background: rgba(37,99,235,.08); color: var(--primary); font-weight: 700; font-size: 12px; }
.status-list { display: grid; gap: 14px; }
.status-list div { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-radius: 16px; background: rgba(248,250,252,.9); border: 1px solid var(--line); }
.status-list span { color: var(--muted); }
.status-list strong { font-size: 22px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; white-space: nowrap; }
th { color: var(--muted); font-weight: 700; background: rgba(248,250,252,.7); }
tr:hover td { background: rgba(37,99,235,.035); }
.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.buy, .badge.filled, .badge.passed { color: var(--green); background: rgba(5,150,105,.09); }
.badge.sell, .badge.failed, .badge.rejected, .badge.risk_rejected { color: var(--red); background: rgba(220,38,38,.09); }
.badge.pending_confirm, .badge.unchecked { color: var(--amber); background: rgba(217,119,6,.1); }
.badge.new, .badge.submitted, .badge.ordered { color: var(--primary); background: rgba(37,99,235,.08); }
.price-up { color: var(--red); font-weight: 700; }
.price-down { color: var(--green); font-weight: 700; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.setting-item { padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: rgba(248,250,252,.74); }
.setting-item label { display: block; font-weight: 700; margin-bottom: 8px; }
.setting-item input, .setting-item select {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; outline: none; background: #fff; color: var(--text);
}
.setting-item input:focus, .setting-item select:focus { border-color: rgba(37,99,235,.6); box-shadow: 0 0 0 4px rgba(37,99,235,.08); }

.toast {
  position: fixed; right: 24px; bottom: 24px; padding: 13px 16px; border-radius: 16px;
  color: #fff; background: rgba(15,23,42,.92); box-shadow: 0 18px 48px rgba(15,23,42,.25);
  transform: translateY(20px); opacity: 0; pointer-events: none; transition: all .22s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1024px) {
  .app-shell { display: block; }
  .sidebar { position: relative; width: 100%; height: auto; border-radius: 0 0 30px 30px; }
  .side-card { position: relative; left: auto; right: auto; bottom: auto; margin-top: 18px; }
  .nav { grid-template-columns: repeat(4, 1fr); }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .grid.two { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .main { padding: 18px; }
  .topbar, .panel-head { align-items: flex-start; flex-direction: column; }
  .cards, .settings-grid { grid-template-columns: 1fr; }
  .nav { grid-template-columns: repeat(2, 1fr); }
}

.compact-cards { margin-top: 18px; }
.hero-panel {
  background:
    linear-gradient(135deg, rgba(37,99,235,.08), rgba(14,165,233,.06)),
    var(--panel);
}
.flow-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.72);
  border: 1px solid var(--line);
}
.flow-line span {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(37,99,235,.08);
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 700;
}
.flow-line i {
  width: 28px;
  height: 1px;
  background: linear-gradient(90deg, rgba(37,99,235,.15), rgba(37,99,235,.7));
}
.strategy-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}
.strategy-card {
  padding: 20px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(255,255,255,.66);
  box-shadow: var(--shadow);
  transition: all .18s ease;
}
.strategy-card:hover { transform: translateY(-2px); box-shadow: 0 26px 68px rgba(15,23,42,.12); }
.strategy-card.disabled { opacity: .62; }
.strategy-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.strategy-type {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(37,99,235,.08);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}
.strategy-card h3 { margin: 10px 0 0; font-size: 18px; letter-spacing: -.04em; }
.strategy-card p { margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; min-height: 44px; }
.strategy-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.strategy-metrics div {
  padding: 12px;
  border-radius: 14px;
  background: rgba(248,250,252,.85);
  border: 1px solid var(--line);
}
.strategy-metrics span { display: block; color: var(--muted); font-size: 12px; }
.strategy-metrics strong { display: block; margin-top: 5px; font-size: 18px; }
.strategy-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.reason-text {
  display: inline-block;
  max-width: 280px;
  white-space: normal;
  line-height: 1.6;
  color: #334155;
}
.reason-text.wide { max-width: 420px; }
.score-bars { display: grid; gap: 4px; min-width: 140px; margin-top: 6px; }
.score-bars div { display: grid; grid-template-columns: 42px 1fr 28px; align-items: center; gap: 6px; }
.score-bars span, .score-bars b { font-size: 11px; color: var(--muted); font-weight: 700; }
.score-bars em {
  height: 6px;
  border-radius: 999px;
  background: rgba(148,163,184,.18);
  overflow: hidden;
}
.score-bars i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #0ea5e9);
}
.badge.true, .badge.正常, .badge.info { color: var(--green); background: rgba(5,150,105,.09); }
.badge.false, .badge.danger { color: var(--red); background: rgba(220,38,38,.09); }
.badge.basic, .badge.technical, .badge.fundamental, .badge.money { color: var(--primary); background: rgba(37,99,235,.08); }
.empty { padding: 28px; border-radius: var(--radius); background: rgba(255,255,255,.86); color: var(--muted); text-align: center; }

@media (max-width: 1180px) {
  .strategy-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .strategy-grid { grid-template-columns: 1fr; }
  .flow-line i { display: none; }
  .strategy-metrics { grid-template-columns: 1fr; }
}

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); font-size: 12px; }
.ai-hero {
  background:
    linear-gradient(135deg, rgba(79,70,229,.10), rgba(14,165,233,.07)),
    var(--panel);
}
.ai-warning {
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(217,119,6,.22);
  background: rgba(217,119,6,.08);
  color: #92400e;
  line-height: 1.65;
  font-size: 13px;
}
.ai-warning strong { color: #7c2d12; }
.badge.hold, .badge.skip, .badge.skipped, .badge.blocked { color: var(--amber); background: rgba(217,119,6,.10); }
.badge.ordered, .badge.analyzed { color: var(--primary); background: rgba(37,99,235,.08); }

/* 登录验证 */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(37,99,235,.22), transparent 30%),
    radial-gradient(circle at 80% 15%, rgba(14,165,233,.18), transparent 32%),
    linear-gradient(135deg, #eff6ff 0%, #f8fafc 48%, #eef2ff 100%);
}
.auth-locked .login-screen { display: flex; }
.auth-locked .app-shell { display: none; }
.login-card {
  width: min(440px, 100%);
  padding: 34px;
  border-radius: 28px;
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(255,255,255,.76);
  box-shadow: 0 32px 90px rgba(15,23,42,.18);
  backdrop-filter: blur(18px);
}
.login-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: white;
  font-weight: 900;
  letter-spacing: -.05em;
  background: linear-gradient(135deg, var(--primary), #0ea5e9);
  box-shadow: 0 18px 36px rgba(37,99,235,.28);
  margin-bottom: 18px;
}
.login-card h1 {
  margin: 6px 0 10px;
  font-size: 28px;
  letter-spacing: -.06em;
  color: var(--text);
}
.login-desc, .login-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}
.login-form { margin-top: 22px; display: grid; gap: 14px; }
.login-form label { display: grid; gap: 8px; color: #334155; font-size: 13px; font-weight: 800; }
.login-form input {
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(248,250,252,.9);
  padding: 0 14px;
  outline: none;
  font-size: 14px;
}
.login-form input:focus {
  border-color: rgba(37,99,235,.55);
  box-shadow: 0 0 0 4px rgba(37,99,235,.10);
  background: #fff;
}
.btn.full { width: 100%; justify-content: center; min-height: 46px; }
.login-error { min-height: 20px; color: var(--red); font-size: 13px; line-height: 1.5; }
.login-note {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(217,119,6,.08);
  color: #92400e;
}
