/* OFT 套利控制台：深色主题，手机 / 桌面自适应。没有外部字体和库（CSP 只允许本站资源） */
:root {
  --bg: #0a0d16;
  --bg2: #0f1422;
  --card: rgba(22, 28, 46, 0.72);
  --card-solid: #141a2b;
  --line: rgba(148, 163, 214, 0.14);
  --line-strong: rgba(148, 163, 214, 0.24);
  --text: #e8ecf7;
  --muted: #8b95b0;
  --faint: #5d6782;
  --up: #2fd492;
  --up-bg: rgba(47, 212, 146, 0.12);
  --down: #ff5d73;
  --down-bg: rgba(255, 93, 115, 0.12);
  --warn: #ffb547;
  --warn-bg: rgba(255, 181, 71, 0.12);
  --accent: #7c6cff;
  --accent2: #2bd4f0;
  --radius: 18px;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.up { color: var(--up); }
.down { color: var(--down); }
.warn { color: var(--warn); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; opacity: 0; }

/* 背景：两团柔和的光 */
.backdrop {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 520px at 8% -8%, rgba(124, 108, 255, 0.20), transparent 60%),
    radial-gradient(800px 480px at 100% 0%, rgba(43, 212, 240, 0.13), transparent 60%),
    radial-gradient(1000px 700px at 50% 120%, rgba(47, 212, 146, 0.06), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
}

/* 标志：两条链之间的桥 */
.mark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, rgba(124, 108, 255, 0.95), rgba(43, 212, 240, 0.9));
  box-shadow: 0 8px 24px rgba(124, 108, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.mark svg { width: 26px; height: 26px; }
.mark-lg { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 18px; }
.mark-lg svg { width: 40px; height: 40px; }
.mark-arc { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; }
.mark-dot { fill: #fff; }
.mark-dot.b { fill: #0a0d16; stroke: #fff; stroke-width: 2.2; }

/* ———————— 登录 ———————— */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 400px; padding: 36px 28px 28px; text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: 0.5px; }
.login-card > .muted { margin: 0 0 26px; font-size: 13px; }
.field { display: block; text-align: left; margin-bottom: 16px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 13px 14px; font-size: 16px; color: var(--text); font-family: var(--mono); letter-spacing: 1px;
  background: rgba(8, 11, 20, 0.6); border: 1px solid var(--line-strong); border-radius: 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(124, 108, 255, 0.18); }
.login-card button {
  width: 100%; padding: 13px; font-size: 15px; font-weight: 600; color: #fff; cursor: pointer; border: 0; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #5b8dff 55%, var(--accent2));
  box-shadow: 0 10px 28px rgba(124, 108, 255, 0.35); transition: transform .1s, filter .15s;
}
.login-card button:hover { filter: brightness(1.08); }
.login-card button:active { transform: translateY(1px); }
.login-card button:disabled { opacity: .6; cursor: wait; }
.err { min-height: 20px; margin: 14px 0 0; color: var(--down); font-size: 13px; }

/* ———————— 页面框架 ———————— */
main { max-width: 1240px; margin: 0 auto; padding: 18px 16px 40px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.title { font-size: 18px; font-weight: 700; letter-spacing: .3px; }
.sub { font-size: 12px; color: var(--muted); }
.top-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 10px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.ghost:hover { color: var(--text); border-color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: rgba(148, 163, 214, 0.1); border: 1px solid var(--line); max-width: 100%; }
.pill b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.pill.ok { color: var(--up); background: var(--up-bg); border-color: rgba(47, 212, 146, 0.25); }
.pill.ok i { background: var(--up); box-shadow: 0 0 0 0 rgba(47, 212, 146, 0.6); animation: pulse 2s infinite; }
.pill.warn { color: var(--warn); background: var(--warn-bg); border-color: rgba(255, 181, 71, 0.25); }
.pill.warn i { background: var(--warn); }
.pill.bad { color: var(--down); background: var(--down-bg); border-color: rgba(255, 93, 115, 0.25); }
.pill.bad i { background: var(--down); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(47, 212, 146, .55); } 70% { box-shadow: 0 0 0 8px rgba(47, 212, 146, 0); } 100% { box-shadow: 0 0 0 0 rgba(47, 212, 146, 0); } }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; margin-bottom: 14px; font-size: 13px; }
.alert.warn { background: var(--warn-bg); border: 1px solid rgba(255, 181, 71, 0.3); color: #ffd99a; }
.alert.bad { background: var(--down-bg); border: 1px solid rgba(255, 93, 115, 0.3); color: #ffb3bd; }
.alert pre { margin: 6px 0 0; white-space: pre-wrap; font-family: var(--mono); font-size: 12px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  margin-bottom: 16px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: .3px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 16px; }
.grid2 + .card, .grid2 + .grid2 { margin-top: 0; }

/* ———————— 指标卡 ———————— */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 0; }
.kpi { position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: linear-gradient(90deg, var(--accent), var(--accent2)); opacity: .7; }
.kpi .k-label { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.kpi .k-value { font-size: 30px; font-weight: 750; letter-spacing: -.5px; margin: 6px 0 4px; font-variant-numeric: tabular-nums; line-height: 1.15; white-space: nowrap; }
.kpi .k-value.mid { font-size: 22px; }
.kpi .k-sub { font-size: 12px; color: var(--muted); }
.kpi .k-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; margin-top: 4px; }
.kpi .k-row span:last-child { font-variant-numeric: tabular-nums; color: var(--text); }
.bar-mini { height: 6px; border-radius: 99px; background: rgba(148, 163, 214, 0.12); overflow: hidden; margin: 8px 0 2px; display: flex; }
.bar-mini i { display: block; height: 100%; background: var(--up); }
.bar-mini i.loss { background: var(--down); }

/* ———————— 分段按钮 ———————— */
.seg { display: inline-flex; background: rgba(8, 11, 20, 0.5); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { background: transparent; border: 0; color: var(--muted); padding: 5px 12px; border-radius: 8px; cursor: pointer; font-size: 12px; }
.seg button.on { background: rgba(124, 108, 255, 0.22); color: var(--text); }

/* ———————— 图表 ———————— */
.chart { width: 100%; height: 300px; position: relative; }
.chart svg { display: block; width: 100%; height: 100%; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .zero { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 4 4; }
.chart .axis { fill: var(--faint); font-size: 11px; font-family: var(--sans); }
.chart .area { fill: url(#areaGrad); }
.chart .line { fill: none; stroke: url(#lineGrad); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--bg); stroke: var(--accent2); stroke-width: 2; }
.chart .bar-up { fill: var(--up); opacity: .85; }
.chart .bar-down { fill: var(--down); opacity: .85; }
.chart .guide { stroke: rgba(232, 236, 247, 0.35); stroke-width: 1; }
.chart .empty { fill: var(--muted); font-size: 13px; }
.chart-legend { display: flex; align-items: center; gap: 6px; margin: -4px 0 8px; flex-wrap: wrap; }
.lg { display: inline-block; width: 14px; height: 4px; border-radius: 3px; margin-left: 8px; }
.lg:first-child { margin-left: 0; }
.lg.line { background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.lg.bar-up { background: var(--up); height: 8px; width: 8px; }
.lg.bar-down { background: var(--down); height: 8px; width: 8px; }
.tip {
  position: fixed; z-index: 10; pointer-events: none; min-width: 180px; max-width: 280px;
  background: rgba(14, 18, 32, 0.96); border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 12px; font-size: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.tip .t-title { font-weight: 650; margin-bottom: 4px; }
.tip .t-row { display: flex; justify-content: space-between; gap: 12px; }
.tip .t-row span:last-child { font-variant-numeric: tabular-nums; }

/* ———————— 列表（键值） ———————— */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); white-space: nowrap; }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.svc { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.svc:last-child { border-bottom: 0; }
.svc .name { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--up); box-shadow: 0 0 10px rgba(47, 212, 146, .6); }
.dot.bad { background: var(--down); box-shadow: 0 0 10px rgba(255, 93, 115, .5); }
.dot.warn { background: var(--warn); }
.section-title { font-size: 12px; color: var(--muted); margin: 14px 0 6px; letter-spacing: .4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: rgba(124, 108, 255, 0.14); border: 1px solid rgba(124, 108, 255, 0.28); color: #cfc9ff; }

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: rgba(8, 11, 20, 0.45); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.stat .s-label { font-size: 11px; color: var(--muted); }
.stat .s-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .s-sub { font-size: 11px; color: var(--faint); }

/* ———————— 交易表 ———————— */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; -webkit-overflow-scrolling: touch; }
table.trades { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 900px; }
table.trades th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; position: sticky; top: 0; }
table.trades td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
table.trades tr:hover td { background: rgba(124, 108, 255, 0.05); }
table.trades td.r, table.trades th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.trades td:first-child, table.trades th:first-child { position: sticky; left: 0; background: var(--card-solid); z-index: 1; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 6px; margin-left: 6px; border: 1px solid var(--line-strong); color: var(--muted); }
.tag.fast { color: #b9b0ff; border-color: rgba(124, 108, 255, 0.4); background: rgba(124, 108, 255, 0.1); }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.badge.ok { color: var(--up); background: var(--up-bg); }
.badge.loss { color: var(--down); background: var(--down-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.muted { color: var(--muted); background: rgba(148, 163, 214, 0.1); }
.sub-line { display: block; font-size: 11px; color: var(--faint); margin-top: 3px; white-space: normal; max-width: 320px; }
table.trades td.c-res, table.trades td.c-trig { white-space: normal; min-width: 96px; max-width: 220px; }
table.trades td.c-speed { white-space: nowrap; line-height: 1.7; }
table.trades td.c-speed .sp2 { display: block; }
table.trades td.c-net b { font-size: 14px; }
table.trades td.c-pos { white-space: normal; min-width: 120px; max-width: 220px; }
table.trades td.c-pos .sub-line { font-family: var(--sans); }
.links a { margin-right: 8px; font-size: 12px; }
.speed { font-size: 12px; color: var(--muted); }
.speed b { color: var(--text); font-weight: 600; }
.empty-row td { text-align: center; color: var(--muted); padding: 30px; }

/* ———————— 小列表（调钱 / 策略 / 监控） ———————— */
.list { display: flex; flex-direction: column; }
.li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.li:last-child { border-bottom: 0; }
.li .l-main { min-width: 0; }
.li .l-title { font-weight: 600; }
.li .l-sub { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.li .l-right { text-align: right; font-variant-numeric: tabular-nums; flex: none; }
.spread { display: grid; grid-template-columns: 72px 1fr 1fr; gap: 6px 10px; font-size: 12.5px; align-items: center; }
.spread .h { color: var(--faint); font-size: 11px; }
.spread .tok { font-weight: 600; }
.spread .v { font-variant-numeric: tabular-nums; }

/* ———————— 日志 ———————— */
details summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
details summary::-webkit-details-marker { display: none; }
details summary h2::before { content: "▸"; display: inline-block; margin-right: 8px; color: var(--muted); transition: transform .15s; }
details[open] summary h2::before { transform: rotate(90deg); }
.log {
  margin: 14px 0 0; max-height: 460px; overflow: auto; padding: 12px 14px; border-radius: 12px; background: rgba(5, 7, 13, 0.75); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55; color: #c3cbe0; white-space: pre-wrap; word-break: break-all;
}
.log .l-warn { color: var(--warn); }
.log .l-bad { color: var(--down); }
.log .l-ok { color: var(--up); }
.log .l-child { color: var(--faint); }
footer { text-align: center; margin-top: 8px; }

/* ———————— 自适应 ———————— */
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis .card { margin-bottom: 0; }
  .kpis { margin-bottom: 16px; }
}
@media (max-width: 820px) {
  .grid2 { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 720px) {
  .table-wrap { overflow: visible; margin: 0; padding: 0; }
  table.trades { min-width: 0; display: block; }
  table.trades thead { display: none; }
  table.trades tbody { display: flex; flex-direction: column; gap: 10px; }
  table.trades tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 12px 14px;
    grid-template-areas: "time res" "strat net" "money money" "trig trig" "speed speed" "pos links";
    border: 1px solid var(--line); border-radius: 14px; background: rgba(8, 11, 20, 0.45);
  }
  table.trades tr:hover td { background: none; }
  table.trades td, table.trades td:first-child { display: block; padding: 0; border: 0; position: static; background: none; white-space: normal; max-width: none; min-width: 0; text-align: left; }
  table.trades td.c-time { grid-area: time; color: var(--muted); font-size: 12px; }
  table.trades td.c-res { grid-area: res; text-align: right; }
  table.trades td.c-strat { grid-area: strat; font-weight: 650; font-size: 14px; }
  table.trades td.c-net { grid-area: net; text-align: right; }
  table.trades td.c-net b { font-size: 18px; }
  table.trades td.c-net .sub-line { margin-top: 0; }
  table.trades td.c-money { grid-area: money; color: var(--muted); font-size: 12px; text-align: left; }
  table.trades td.c-money::before { content: "花 "; }
  table.trades td.c-money .sub-line { display: inline; font-size: 12px; color: var(--muted); margin-left: 4px; }
  table.trades td.c-trig { grid-area: trig; font-size: 12px; color: var(--muted); }
  table.trades td.c-trig::before { content: "触发 "; color: var(--faint); }
  table.trades td.c-trig .sub-line { display: inline; margin-left: 6px; }
  table.trades td.c-speed { grid-area: speed; }
  table.trades td.c-speed .sp2 { display: inline; }
  table.trades td.c-speed .sp2.after::before { content: " · "; }
  table.trades td.c-pos { grid-area: pos; color: var(--faint); align-self: center; }
  table.trades td.c-links { grid-area: links; text-align: right; }
  table.trades td.c-res .sub-line { text-align: right; margin-left: auto; max-width: 240px; }
  .empty-row td { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  main { padding: 12px 12px 32px; }
  .kpis { grid-template-columns: 1fr; gap: 12px; }
  .kpi .k-value { font-size: 28px; }
  .card { padding: 15px; border-radius: 16px; margin-bottom: 12px; }
  .table-wrap { margin: 0 -15px; padding: 0 15px; }
  .chart { height: 240px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top-right { width: 100%; justify-content: space-between; }
  .title { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) { .pill.ok i { animation: none; } }
