:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --card2: #f8fafc;
  --border: #e6e9f0;
  --border2: #d5dae4;
  --text: #0f172a;
  --text2: #334155;
  --muted: #64748b;
  --dim: #94a3b8;
  --green: #16a34a;
  --green-bg: #ecfdf3;
  --red: #e11d48;
  --red-bg: #fff1f2;
  --yellow: #b45309;
  --yellow-bg: #fffbeb;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --violet: #6d28d9;
  --violet-bg: #f5f3ff;
  --accent: #5b5bf7;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 18px rgba(16, 24, 40, .06);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
  --radius: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-size: 13.5px; line-height: 1.55;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
h3 { margin: 0; font-size: 15px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.pos { color: var(--green); } .neg { color: var(--red); } .mut, .muted { color: var(--muted); } .yel { color: var(--yellow); }
.small { font-size: 12px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 20px;
  padding: 10px 24px; background: rgba(255,255,255,.88); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); box-shadow: 0 1px 0 rgba(16,24,40,.02);
}
.brand { display: flex; align-items: center; gap: 11px; }
.logo {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-weight: 800;
  background: linear-gradient(135deg, #6366f1, #8b5cf6 60%, #ec4899); box-shadow: 0 6px 16px rgba(99,102,241,.35);
}
.brand-title { font-weight: 800; font-size: 15px; }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.nav { display: flex; gap: 2px; }
.nav a { color: var(--text2); padding: 6px 11px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.nav a:hover { background: var(--card2); color: var(--accent); }

/* ---------- 页面 Tab：交易台 / 历史轮次 / 每日盈亏 / 策略参数 / 历史回测 / 决策日志 ---------- */
.page-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.page-tabs a { padding: 9px 18px; font-size: 14px; font-weight: 700; color: var(--text2); border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 8px 8px 0 0; }
.page-tabs a:hover { background: var(--card2); color: var(--accent); }
.page-tabs a.on { color: var(--violet); border-bottom-color: var(--violet); }
body[data-view="backtest"] .wrap > :not(#backtest):not(#pageTabs):not(#alert):not(footer),
body[data-view="params"] .wrap > :not(#params):not(#pageTabs):not(#alert):not(footer),
body[data-view="logs"] .wrap > :not(#logs):not(#pageTabs):not(#alert):not(footer),
body[data-view="histRounds"] .wrap > :not(#pageTabs):not(#alert):not(footer):not(.grid-pricing-sig-hist) { display: none; }
body[data-view="histRounds"] .grid-pricing-sig-hist { display: block; grid-template-columns: 1fr; }
body[data-view="histRounds"] .grid-pricing-sig-hist > :not(#histRounds) { display: none; }
body[data-view="dailyPnl"] .wrap > :not(#dailyPnl):not(#pageTabs):not(#alert):not(footer) { display: none; }
/* 直接用独立 Tab 锚点打开时，不要把 tab 栏顶出屏幕 */
#params, #backtest, #logs, #histRounds, #dailyPnl { scroll-margin-top: 140px; }
body:not([data-view="backtest"]) #backtest,
body:not([data-view="params"]) #params,
body:not([data-view="logs"]) #logs,
body:not([data-view="dailyPnl"]) #dailyPnl { display: none; }
body[data-view="histRounds"] #histRounds {
  min-height: calc(100vh - 180px);
  display: flex;
  flex-direction: column;
}
body[data-view="histRounds"] #histRounds .hist-rounds-scroll,
body[data-view="dailyPnl"] #dailyPnl .daily-pnl-scroll { flex: 1 1 auto; min-height: 320px; max-height: min(72vh, 920px); }
body[data-view="main"] #histRounds .hist-rounds-scroll { flex: 1 1 0; min-height: 200px; max-height: none; }
body[data-view="histRounds"] .hist-more { display: none; }
.conn { display: flex; gap: 8px; flex: 1; justify-content: flex-end; flex-wrap: wrap; }
.conn span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); background: var(--card2); border: 1px solid var(--border); padding: 3px 9px; border-radius: 999px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); display: inline-block; }
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.dot.warn { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.15); }
.dot.bad { background: var(--red); box-shadow: 0 0 0 3px rgba(225,29,72,.15); }
.actions { display: flex; gap: 8px; align-items: center; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--card2); color: var(--text2); border: 1px solid var(--border); }
.pill.ok, .tone-green { background: var(--green-bg); color: var(--green); border-color: #bbf7d0; }
.pill.bad, .tone-red { background: var(--red-bg); color: var(--red); border-color: #fecdd3; }
.pill.warn, .tone-yellow { background: var(--yellow-bg); color: var(--yellow); border-color: #fde68a; }
.tone-blue { background: var(--blue-bg); color: var(--blue); border-color: #bfdbfe; }
.tone-violet { background: var(--violet-bg); color: var(--violet); border-color: #ddd6fe; }
.tone-gray { background: var(--card2); color: var(--muted); border-color: var(--border); }

.btn {
  padding: 7px 14px; border-radius: 10px; border: 1px solid var(--border2); background: #fff; color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; white-space: nowrap; transition: all .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn.run { background: var(--green); border-color: var(--green); color: #fff; }
.btn.run:hover { filter: brightness(1.05); color: #fff; }
.btn.pause { background: #fff7ed; border-color: #fdba74; color: #c2410c; }
.btn.danger { color: var(--red); border-color: #fecdd3; }
.btn.danger:hover { background: var(--red-bg); }
.btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 布局 ---------- */
.wrap { padding: 20px 24px 40px; display: grid; gap: 16px; max-width: 1640px; margin: 0 auto; }
.grid3 { display: grid; grid-template-columns: 1fr 1.35fr 1fr; gap: 16px; align-items: stretch; }
.grid3 > .btc-market-panel { min-width: 0; }
.grid3 > .card-price-chart {
  display: flex; flex-direction: column; min-width: 0; min-height: 320px; height: 100%;
}
.grid3 > .card-price-chart #klinePanel,
.grid3 > .card-price-chart #fairPanel:not([hidden]) {
  /* flex-basis 用 auto：面板至少占「工具栏 + 图表最小高度」，卡片没被同行拉高时（如窄屏单列）图表不会溢出卡片 */
  display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-pricing-sig-hist {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 16px;
  align-items: stretch;
}
body[data-view="main"] .grid-pricing-sig-hist {
  height: 500px;
  min-height: 500px;
  max-height: 500px;
}
body[data-view="main"] .card-pricing-sig,
body[data-view="main"] .grid-pricing-sig-hist #histRounds {
  height: 100%;
  max-height: 500px;
  min-height: 0;
}
.card-pricing-sig {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  padding-bottom: 18px;
}
.card-pricing-sig-h { align-items: center; margin-bottom: 14px; }
.card-pricing-sig-h .seg { flex: 1 1 auto; min-width: 0; }
.card-pricing-sig-h .seg button { padding: 6px 12px; font-size: 12.5px; }
.pricing-sig-pane { flex: 1 1 0; min-height: 0; overflow-y: auto; padding-bottom: 6px; }
.card-pricing-sig .price-cards { gap: 12px; margin-bottom: 4px; }
.card-pricing-sig .pc { padding: 12px 13px; }
.card-pricing-sig .pc-row { padding: 3px 0; }
.card-pricing-sig .edge { margin-top: 8px; gap: 8px; }
.card-pricing-sig .notes { margin-top: 14px; line-height: 1.55; }
.card-pricing-sig .pricing-stats-h { margin-top: 18px; margin-bottom: 8px; }
.card-pricing-sig .stats-in-pricing { gap: 10px; }
.grid-pricing-sig-hist #histRounds { min-width: 0; display: flex; flex-direction: column; align-self: stretch; }
.grid-pricing-sig-hist #histRounds .card-h { flex-wrap: wrap; gap: 6px 10px; }
.grid-pricing-sig-hist #histRounds .hist-more { margin-left: auto; font-weight: 600; }
.grid-pricing-sig-hist #histRounds .hist-rounds-scroll { flex: 1 1 0; min-height: 0; }
.grid-pricing-sig-hist #histRounds .tbl { font-size: 12px; }
.grid-pricing-sig-hist #histRounds .tbl th,
.grid-pricing-sig-hist #histRounds .tbl td { padding: 6px 8px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-h:has(#posNote) h3 { white-space: nowrap; }
#posNote { text-align: right; line-height: 1.45; }
.card-h.wrap-h { flex-wrap: wrap; align-items: flex-start; }
.sub-h { font-size: 12px; color: var(--muted); font-weight: 700; margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .3px; }
.link { font-size: 12px; font-weight: 600; }
.alert { padding: 10px 14px; border-radius: 12px; background: var(--red-bg); border: 1px solid #fecdd3; color: #9f1239; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(180deg, #6366f1, #a855f7); opacity: .85; }
.kpi-l { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-v { font-size: 22px; font-weight: 800; margin-top: 2px; letter-spacing: -.3px; }
.kpi-s { font-size: 12px; color: var(--muted); min-height: 18px; }

/* 本局 */
.round-title { font-size: 13.5px; font-weight: 600; color: var(--text2); }
.countdown-row { display: flex; align-items: center; gap: 12px; margin: 6px 0 12px; }
.countdown { font-size: 42px; font-weight: 800; letter-spacing: -1.5px; line-height: 1; }
.phasebar { position: relative; display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--card2); }
.phasebar div { height: 100%; }
.phasebar .marker { position: absolute; top: -3px; width: 4px; height: 16px; background: var(--text); border-radius: 2px; border: 1px solid #fff; }
.phase-legend { display: flex; justify-content: space-between; font-size: 11px; color: var(--dim); margin: 4px 0 12px; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kv > div {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card2); border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px;
}
.kv .l { font-size: 11.5px; color: var(--muted); flex: 1; min-width: 0; }
.kv .v { font-weight: 700; font-size: 14px; text-align: right; flex-shrink: 0; }

/* 定价卡 */
.price-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pc { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--card2); }
.pc.up { border-top: 3px solid var(--green); }
.pc.down { border-top: 3px solid var(--red); }
.pc-h { display: flex; justify-content: space-between; align-items: baseline; }
.pc-name { font-weight: 800; font-size: 14px; }
.pc-fair { font-size: 22px; font-weight: 800; }
.pc-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 2px 0; color: var(--text2); }
.pc-row span:first-child { color: var(--muted); }
.edge { margin-top: 6px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.edge div { text-align: center; border-radius: 8px; padding: 4px; font-size: 12px; font-weight: 700; background: #fff; border: 1px solid var(--border); }
.edge small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.notes { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* 信号 */
.sig-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.sig {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px;
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; background: var(--card2);
}
.sig .l { font-size: 11.5px; color: var(--muted); flex: 1; min-width: 0; }
.sig .v { font-weight: 700; text-align: right; flex-shrink: 0; }
.sig .bar { flex: 0 0 100%; margin-top: 2px; }
.sig .bar { height: 4px; border-radius: 2px; background: #e2e8f0; margin-top: 4px; overflow: hidden; position: relative; }
.sig .bar i { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.risk { margin-top: 12px; padding: 10px 12px; border-radius: 12px; font-size: 12.5px; }
.risk.ok { background: var(--green-bg); border: 1px solid #bbf7d0; color: #166534; }
.risk.block { background: var(--yellow-bg); border: 1px solid #fde68a; color: #92400e; }

/* 图表 */
.chart { width: 100%; height: 240px; display: block; }
/* 卡片会被同一行的 BTC 行情面板拉高，图表跟着撑满剩余高度（最少 300px）。
   flex-basis 为 0 + overflow:hidden：图表自身的画布高度不反过来撑高卡片，面板变矮时能跟着缩回去 */
.card-price-chart { display: flex; flex-direction: column; }
.card-price-chart .wrap-h { align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-price-chart .kline-toolbar { padding: 0 4px 8px; }
.card-price-chart .kline-seg button { padding: 4px 10px; font-size: 12px; }
.card-price-chart .fair-hint { margin: 0 0 6px; padding: 0 4px; }
.card-price-chart .price-echart-host {
  width: 100%; flex: 1 1 0; min-height: 300px; position: relative; overflow: hidden;
}
.card-price-chart .chart-message {
  position: absolute; inset: 45% 10% auto; text-align: center;
  color: #94a3b8; font-size: 13px; pointer-events: none;
}
.card-h:has(.chart-tools) h3 { white-space: nowrap; }
.chart-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.chart-tools .seg button { padding: 4px 10px; font-size: 12px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

/* 持仓 */
.pos-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pos-cell { background: var(--card2); border: 1px solid var(--border); border-radius: 12px; padding: 8px 10px; }
.pos-cell .l { font-size: 11.5px; color: var(--muted); }
.pos-cell .v { font-size: 16px; font-weight: 800; }

.tbl-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; max-height: 190px; }
.tbl-wrap.tall { max-height: 520px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { position: sticky; top: 0; background: var(--card2); color: var(--muted); font-weight: 600; font-size: 11.5px; text-align: left; padding: 7px 9px; white-space: nowrap; border-bottom: 1px solid var(--border); }
.tbl td { padding: 6px 9px; border-top: 1px solid #f1f5f9; white-space: nowrap; }
.tbl td.wrap { white-space: normal; min-width: 260px; color: var(--text2); }
.tbl tr:hover td { background: #fafbff; }
.tbl .empty { color: var(--dim); text-align: center; padding: 16px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 700; margin-right: 3px; border: 1px solid transparent; }

/* 订单簿 */
.books { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.book-card { border: 1px solid var(--border); border-radius: 12px; padding: 10px; background: var(--card2); }
.book-title { font-weight: 800; margin-bottom: 4px; }
.book-title.up { color: var(--green); } .book-title.down { color: var(--red); }
.book { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.book td { padding: 3px 6px; position: relative; }
.book td:last-child { text-align: right; color: var(--text2); }
.book tr.ask td:first-child { color: var(--red); font-weight: 600; }
.book tr.bid td:first-child { color: var(--green); font-weight: 600; }
.book tr.mid td { text-align: center !important; color: var(--muted); font-size: 11.5px; padding: 5px; border-top: 1px dashed var(--border2); border-bottom: 1px dashed var(--border2); }
.book .bar { position: absolute; right: 0; top: 2px; bottom: 2px; border-radius: 4px; opacity: .14; }

/* 策略参数 */
.param-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.save-state { font-size: 12px; font-weight: 600; min-width: 80px; text-align: right; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.tabs button { background: none; border: 1px solid transparent; padding: 6px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text2); cursor: pointer; font-family: inherit; }
.tabs button:hover { background: var(--card2); }
.tabs button.on { background: var(--violet-bg); color: var(--violet); border-color: #ddd6fe; }
.tabs button .cnt { font-size: 11px; color: var(--muted); margin-left: 4px; }
.tabs button.on .cnt { color: var(--violet); }
.param-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.pcard { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; background: #fff; transition: border-color .15s, box-shadow .15s; }
.pcard:hover { border-color: #c7d2fe; box-shadow: 0 4px 14px rgba(99,102,241,.08); }
.pcard.changed { border-color: #c4b5fd; background: #fcfbff; }
.pcard.flash { box-shadow: 0 0 0 3px rgba(22,163,74,.25); border-color: #86efac; }
.pcard-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pcard-l { font-size: 13px; font-weight: 600; color: var(--text); }
.pcard-note { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.pcard-def { font-size: 11px; color: var(--dim); }
.reset { border: none; background: none; color: var(--violet); cursor: pointer; font-size: 13px; padding: 0 2px; }
.pcard-ctl { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.pcard-ctl input[type=range] { flex: 1; accent-color: var(--accent); height: 4px; }
.pcard-ctl input[type=number], .pcard-ctl input[type=text] {
  width: 92px; padding: 6px 8px; border: 1px solid var(--border2); border-radius: 8px; font-size: 13px; font-family: inherit; color: var(--text); background: #fff;
}
.pcard-ctl input[type=text] { width: 100%; }
.pcard-ctl input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,91,247,.15); }
.switch { position: relative; width: 42px; height: 24px; flex: none; margin-left: auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opts button { border: 1px solid var(--border2); background: #fff; border-radius: 8px; padding: 5px 10px; font-size: 12px; cursor: pointer; font-family: inherit; color: var(--text2); }
.opts button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 回测 */
.sel { padding: 6px 10px; border: 1px solid var(--border2); border-radius: 9px; font-family: inherit; font-size: 12.5px; background: #fff; color: var(--text); }
.bt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.bt-box { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; background: var(--card2); min-width: 0; }
.bt-box .sub-h { margin-top: 0; }
.verdict { border-radius: 14px; padding: 14px 16px; border: 1px solid; display: grid; gap: 6px; }
.verdict.bad { background: var(--red-bg); border-color: #fecdd3; color: #881337; }
.verdict.good { background: var(--green-bg); border-color: #bbf7d0; color: #14532d; }
.verdict.neutral { background: var(--yellow-bg); border-color: #fde68a; color: #78350f; }
.verdict b { font-size: 15px; }
.verdict ul { margin: 2px 0 0; padding-left: 18px; }
.hbar { display: grid; grid-template-columns: 120px 1fr 64px; gap: 10px; align-items: center; font-size: 12.5px; margin: 6px 0; }
.hbar .track { height: 10px; background: #e2e8f0; border-radius: 6px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 6px; }
.cbar { position: relative; height: 8px; background: #e2e8f0; border-radius: 4px; min-width: 90px; }
.cbar i { position: absolute; top: -3px; width: 3px; height: 14px; border-radius: 2px; }
@media (max-width: 900px) { .bt-grid { grid-template-columns: 1fr; } }

/* 日志 */
.seg { display: inline-flex; border: 1px solid var(--border2); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { background: none; border: none; color: var(--text2); padding: 6px 12px; font-size: 12.5px; cursor: pointer; font-family: inherit; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--violet-bg); color: var(--violet); font-weight: 700; }
.log { max-height: 400px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
body[data-view="logs"] #logs .log { max-height: min(72vh, 920px); }
.log .e { display: grid; grid-template-columns: 72px 46px 64px 1fr; gap: 10px; align-items: start; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--card2); font-size: 12.5px; }
.log .ts { color: var(--dim); }
.log .rt { color: var(--muted); font-weight: 600; }
.log .k { font-weight: 700; font-size: 11px; text-align: center; border-radius: 6px; padding: 1px 0; }
.k-trade { background: var(--green-bg); color: var(--green); }
.k-order { background: var(--blue-bg); color: var(--blue); }
.k-cancel { background: #f1f5f9; color: var(--muted); }
.k-block { background: #f8fafc; color: var(--dim); }
.k-settle { background: var(--violet-bg); color: var(--violet); }
.k-warn { background: var(--yellow-bg); color: var(--yellow); }
.k-info { background: #ecfeff; color: #0e7490; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.card-pricing-sig .stats-in-pricing,
.card-pricing .stats-in-pricing { grid-template-columns: repeat(2, 1fr); }
.card-pricing-sig .stats-in-pricing .stat .v,
.card-pricing .stats-in-pricing .stat .v { font-size: 15px; }
.stat {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card2); border: 1px solid var(--border); border-radius: 12px; padding: 8px 11px;
}
.stat .l { font-size: 11.5px; color: var(--muted); flex: 1; min-width: 0; }
.stat .v { font-size: 15px; font-weight: 800; text-align: right; flex-shrink: 0; }

footer { color: var(--dim); font-size: 12px; text-align: center; padding: 10px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-lg);
}

@media (max-width: 1350px) { .kpis { grid-template-columns: repeat(3, 1fr); } .nav { display: none; } }
@media (max-width: 1200px) { .grid3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) {
  .grid3, .grid2, .grid-pricing-sig-hist { grid-template-columns: 1fr; }
  .conn { display: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .brand-sub { display: none; }
  .actions { margin-left: auto; }
  .wrap { padding: 12px; gap: 12px; }
  .pos-grid { grid-template-columns: repeat(2, 1fr); }
  .price-cards, .books { grid-template-columns: 1fr; }
  .log .e { grid-template-columns: 44px 56px 1fr; }
  .log .e .ts { display: none; }
  .param-grid { grid-template-columns: 1fr; }
}
