/* Algo Optimizer 终端样式：深海军蓝底 + 青绿/琥珀数据色，Space Grotesk 标题 + IBM Plex Mono 数字 */
:root {
  --bg: #0d1420; --surface: #131c2b; --surface2: #182338; --border: #22304a;
  --text: #e8eef7; --muted: #8fa3bf; --faint: #5c7089;
  --up: #2dd4a7; --warn: #f5b942; --down: #f2637e; --accent: #4da3ff;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --font-body: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; margin: 0; }
html { color-scheme: dark; }
body { background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 14px; line-height: 1.55; min-height: 100vh; }
/* 环境背景：细网格 + 双色微光 */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(45, 212, 167, .07), transparent 60%),
    radial-gradient(800px 520px at 95% 108%, rgba(245, 185, 66, .05), transparent 60%),
    repeating-linear-gradient(0deg, rgba(140, 170, 210, .03) 0 1px, transparent 1px 44px),
    repeating-linear-gradient(90deg, rgba(140, 170, 210, .03) 0 1px, transparent 1px 44px);
}
/* ── 顶栏 ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: rgba(13, 20, 32, .85); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark { color: var(--up); font-size: 20px; animation: pulse 3s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.brand-name { font-family: var(--font-display); font-weight: 700; letter-spacing: .12em; font-size: 16px; }
.brand-sub { color: var(--muted); font-size: 12px; letter-spacing: .2em; }
.topnav { display: flex; gap: 4px; }
.topnav a { color: var(--muted); text-decoration: none; padding: 7px 14px; border-radius: 6px; font-size: 13px; position: relative; transition: color .2s, background .2s; }
.topnav a:hover { color: var(--text); background: var(--surface2); }
.topnav a.active { color: var(--up); }
.topnav a.active::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 2px; height: 2px; background: var(--up); border-radius: 2px; animation: slidein .25s ease; }
@keyframes slidein { from { transform: scaleX(0); } }
/* ── 布局 ── */
.app { max-width: 1180px; margin: 0 auto; padding: 26px 24px 60px; }
.grid2 { display: grid; grid-template-columns: 380px 1fr; gap: 22px; align-items: start; }
.page-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: .02em; margin-bottom: 4px; }
.page-hint { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
/* ── 卡片 ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 18px 20px; margin-bottom: 18px; transition: border-color .25s; animation: rise .35s ease both; }
.card:hover { border-color: #2f4262; }
.card h3 { font-family: var(--font-display); font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card h3::before { content: ""; width: 3px; height: 14px; background: var(--up); border-radius: 2px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.card:nth-child(2) { animation-delay: .05s; } .card:nth-child(3) { animation-delay: .1s; }
.card { position: relative; }
/* 搜索下拉框需浮于后续 card 之上；rise 动画的 transform/opacity 创建层叠上下文，
   需在 card 层级设 z-index 才能让 dropdown 逃出 */
.card:has(.search-wrap) { z-index: 10; }
/* ── 表单 ── */
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; letter-spacing: .05em; }
input, select { width: 100%; background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 9px 11px; font-size: 14px; font-family: inherit; transition: border-color .2s, box-shadow .2s; outline: none; }
input:focus, select:focus { border-color: var(--up); box-shadow: 0 0 0 3px rgba(45, 212, 167, .12); }
input::placeholder { color: var(--faint); }
.param-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.hint { font-size: 11px; color: var(--faint); margin-top: 3px; }
/* 标的搜索下拉 */
.search-wrap { position: relative; }
.dropdown { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; max-height: 240px; overflow-y: auto; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
.dropdown .item { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid rgba(34, 48, 74, .5); transition: background .15s; }
.dropdown .item:hover { background: rgba(45, 212, 167, .08); }
.dropdown .item .code { font-family: var(--font-mono); font-size: 12px; color: var(--accent); }
.dropdown .empty { padding: 12px; color: var(--faint); font-size: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.tag { display: inline-flex; align-items: center; gap: 7px; background: rgba(45, 212, 167, .1); border: 1px solid rgba(45, 212, 167, .35); color: var(--up); border-radius: 20px; padding: 3px 11px; font-size: 12px; font-family: var(--font-mono); animation: rise .2s ease; }
.tag button { background: none; border: none; color: inherit; cursor: pointer; font-size: 13px; padding: 0; line-height: 1; opacity: .7; }
.tag button:hover { opacity: 1; }
/* 按钮 */
.btn { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; background: var(--up); color: #06251c; border: none; border-radius: 6px; padding: 11px 22px; font-size: 14px; font-weight: 700; font-family: var(--font-display); letter-spacing: .06em; transition: transform .15s, box-shadow .15s, filter .15s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(45, 212, 167, .3); }
.btn:active { transform: translateY(0); }
.btn:disabled { filter: grayscale(.6) brightness(.7); cursor: not-allowed; transform: none; box-shadow: none; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); font-weight: 500; }
.btn.ghost:hover { border-color: var(--up); color: var(--up); box-shadow: none; }
/* ── 状态徽章 / 进度 ── */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 20px; font-size: 12px; font-family: var(--font-mono); letter-spacing: .05em; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.completed { color: var(--up); background: rgba(45, 212, 167, .1); }
.badge.running, .badge.pending { color: var(--accent); background: rgba(77, 163, 255, .1); }
.badge.running::before { animation: pulse 1.2s infinite; }
.badge.failed { color: var(--down); background: rgba(242, 99, 126, .1); }
.badge.stopped { color: var(--warn); background: rgba(245, 185, 66, .1); }
.badge.missing { color: var(--faint); background: rgba(92, 112, 137, .12); }
.progress-track { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; margin: 10px 0 6px; }
.progress-bar { height: 100%; border-radius: 4px; transition: width .5s ease; background: repeating-linear-gradient(-45deg, var(--accent) 0 10px, #3b8ae0 10px 20px); background-size: 28px 100%; animation: stripes 1s linear infinite; }
@keyframes stripes { to { background-position: 28px 0; } }
.progress-text { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
/* ── 图表 / 表格 ── */
.chart { height: 420px; width: 100%; }
.chart-fallback { color: var(--faint); font-size: 13px; padding: 40px 0; text-align: center; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; letter-spacing: .06em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid rgba(34, 48, 74, .45); }
tr:hover td { background: rgba(77, 163, 255, .04); }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-size: 12.5px; }
td.pos { color: var(--up); } td.neg { color: var(--down); }
.table-scroll { overflow-x: auto; }
/* 指标摘要条 */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 13px 15px; animation: rise .35s ease both; transition: border-color .2s, transform .2s; }
.stat:hover { border-color: #2f4262; transform: translateY(-2px); }
.stat .k { font-size: 11px; color: var(--muted); letter-spacing: .1em; }
.stat .v { font-family: var(--font-mono); font-size: 21px; font-weight: 600; margin-top: 3px; }
/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: none; color: var(--muted); cursor: pointer; padding: 8px 15px; font-size: 13px; font-family: var(--font-mono); border-bottom: 2px solid transparent; transition: color .2s, border-color .2s; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--up); border-bottom-color: var(--up); }
/* 错误面板 */
.error-panel { background: rgba(242, 99, 126, .07); border: 1px solid rgba(242, 99, 126, .35); border-radius: 8px; padding: 16px 18px; }
.error-panel .title { color: var(--down); font-weight: 700; font-family: var(--font-display); margin-bottom: 8px; }
.error-panel pre { color: #f0a8b8; font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; word-break: break-all; max-height: 260px; overflow-y: auto; }
/* Toast */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 11px 20px; font-size: 13px; z-index: 50; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: rise .25s ease; }
.toast.err { border-color: rgba(242, 99, 126, .5); color: var(--down); }
.muted { color: var(--muted); } .mono { font-family: var(--font-mono); }
.gid-link { color: var(--accent); text-decoration: none; font-family: var(--font-mono); }
.gid-link:hover { text-decoration: underline; }
details.advanced summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 14px; user-select: none; }
details.advanced summary:hover { color: var(--text); }

/* 对比篮 */
.basket-bar { display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-bottom:12px; }
.basket-tag { display:inline-flex; gap:6px; align-items:center; padding:3px 10px; border:1px solid rgba(34,48,74,.8); border-radius:12px; font-size:12px; }
.basket-tag button { background:none; border:none; color:var(--muted); cursor:pointer; }
.search-layer { position:relative; }
.search-layer .dropdown { position:absolute; z-index:20; left:0; right:0; top:100%; }
/* Switch 开关 */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: var(--surface2); border: 1px solid var(--border); border-radius: 22px; transition: .25s; }
.switch .slider::before { content: ""; position: absolute; height: 16px; width: 16px; left: 2px; top: 2px; background: var(--faint); border-radius: 50%; transition: .25s; }
.switch input:checked + .slider { background: rgba(45, 212, 167, .2); border-color: var(--up); }
.switch input:checked + .slider::before { transform: translateX(18px); background: var(--up); }
.switch input:disabled + .slider { opacity: .5; cursor: not-allowed; }

/* 调仓表分页 */
.pager { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.pager button { background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager button:not(:disabled):hover { border-color: var(--up); }

/* ── 移动端自适应 ── */
@media (max-width: 768px) {
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .brand-sub { display: none; }
  .app { padding: 18px 14px 50px; }
  .grid2 { grid-template-columns: 1fr; }
  .chart { height: 320px; }
  .param-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 21px; }
  .stat .v { font-size: 17px; }
}
