:root {
  /* 暖棕画布 + 橄榄深色卡片：--bg 为页面整体背景，--panel 为卡片/控件底色 */
  --bg: #7a4839;
  --bg-deep: #66382b;
  --panel: #2c280e;
  --deep: #211d07;
  --raised: #3a3512;
  --line: #96604b;
  --line-soft: #4d3027;
  --text: #f6efe9;
  --muted: #dcc6ba;
  --accent: #e8c68f;
  --blue: #9dc4e6;
  --up: #f2998d;
  --down: #8ed3b8;
  --danger: #ff9d92;
  /* 中文字形优先本机 Noto Sans SC / Maple Mono，不引入在线 Webfont（离线可用） */
  --mono: "Cascadia Code", "Consolas", "Maple Mono Normal NF CN", "Noto Sans SC", monospace;
  --sans: "Segoe UI", "Noto Sans SC", "PingFang SC", "HarmonyOS Sans SC", "MiSans",
    "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
[v-cloak] {
  display: none;
}
button,
input,
select {
  font: inherit;
}
button,
a,
input,
select {
  outline-offset: 4px;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  color: inherit;
}
/* 字号下限 12px：全站不再出现 12px 以下文本 */
small {
  font-size: 12px;
}
::selection {
  background: #e8c68f40;
}
#app {
  min-height: 100vh;
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 232px;
  padding: 35px 20px 24px;
  border-right: 1px solid var(--line);
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  z-index: 10;
}
.brand {
  display: flex;
  gap: 13px;
  align-items: center;
  padding: 0 10px 42px;
}
.brand b {
  color: var(--accent);
  font:
    50px/1 Georgia,
    serif;
}
.brand > span {
  font:
    700 25px/1.3 Georgia,
    serif;
  letter-spacing: 4px;
}
.brand small {
  display: block;
  font: 12px/1.8 var(--mono);
  letter-spacing: 0.6px;
  color: var(--muted);
}
.nav-caption {
  font-size: 12px;
  letter-spacing: 1px;
  color: #d8bfb2;
  padding: 0 13px 20px;
}
nav {
  display: grid;
  gap: 7px;
}
nav button {
  padding: 13px 14px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: none;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  transition: background 0.15s;
}
nav button > span {
  font: 12px var(--mono);
  opacity: 0.6;
}
nav button i {
  margin-left: auto;
  font-style: normal;
  visibility: hidden;
}
nav button:hover {
  background: var(--bg);
  color: var(--text);
}
nav button.selected {
  background: #8a5342;
  border-color: #e8c68f40;
  color: var(--accent);
}
nav button.selected i {
  visibility: visible;
}
.sidebar-bottom {
  margin-top: auto;
  padding: 30px 12px 0;
}
.sidebar-bottom p {
  font-size: 12px;
  line-height: 2;
  color: var(--muted);
  margin: 13px 0 25px;
}
.instrument {
  font: 16px var(--mono);
  padding: 18px 0;
  border-top: 1px solid var(--line);
}
.instrument small {
  display: block;
  font: 12px var(--mono);
  letter-spacing: 1px;
  color: var(--muted);
  margin-top: 9px;
}
.sidebar-bottom > .button {
  width: 100%;
  margin-top: 10px;
}
main {
  margin-left: 232px;
}
.topbar {
  height: 73px;
  padding: 0 36px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}
.topbar > div > span:not(.connection) {
  margin: 0 14px;
  color: #dfbda6;
}
.top-actions {
  display: flex;
  gap: 23px;
  align-items: center;
}
.connection {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.connection i {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b28f7f;
}
.connection.online i {
  background: var(--down);
  box-shadow: 0 0 0 4px #8ed3b81f;
}
.connection.error i {
  background: var(--danger);
}
.connection-mode {
  padding-left: 8px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.workspace {
  max-width: none;
  margin: 0 auto;
  padding: 30px 24px 0;
}
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}
.eyebrow {
  font: 12px var(--mono);
  letter-spacing: 2px;
  color: var(--accent);
}
h1 {
  font-size: 29px;
  letter-spacing: 1.5px;
  font-weight: 500;
  margin: 10px 0 5px;
}
.page-heading p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
.heading-clock {
  display: grid;
  gap: 4px;
  text-align: right;
}
.heading-clock > span,
.heading-clock small {
  color: var(--muted);
  font-size: 12px;
}
.heading-clock strong {
  font: 12px var(--mono);
  font-weight: 400;
}
.filterbar {
  display: flex;
  align-items: center;
  gap: 17px;
  flex-wrap: wrap;
  padding: 14px 0 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
label {
  font-size: 12px;
  color: var(--muted);
}
.filterbar label {
  display: flex;
  align-items: center;
  gap: 10px;
}
.filterbar select {
  max-width: 250px;
}
.mode-label {
  font: 12px var(--mono);
  text-transform: uppercase;
  color: var(--blue);
  border: 1px solid #9dc4e640;
  padding: 3px 8px;
  border-radius: 3px;
}
.refresh-label {
  margin-left: auto;
}
input,
select {
  border: 1px solid var(--line-soft);
  background: var(--panel);
  color: var(--text);
  border-radius: 4px;
  padding: 8px 12px;
  min-width: 0;
}
select {
  font-size: 12px;
}
input:focus,
select:focus {
  border-color: var(--accent);
}
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  border: 1px solid #a4694f;
  background: #5f3629;
  padding: 8px 15px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  transition: background 0.15s;
}
.button:hover {
  background: #74432f;
}
/* SSE 自动读取保留并发锁，但不让按钮反复变暗或变宽。 */
.refresh-button:disabled[aria-busy="true"] {
  opacity: 1;
  cursor: default;
}
.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #2b1b15;
  font-weight: 600;
}
.button.small {
  padding: 5px 11px;
}
.text-button {
  font-size: 12px;
  border: 0;
  background: none;
  padding: 3px;
  color: var(--accent);
}
.notice {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  padding: 12px 15px;
  margin: 16px 0;
  font-size: 12px;
  border-radius: 4px;
}
.notice strong {
  white-space: nowrap;
}
.notice span {
  color: var(--muted);
}
.notice button {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--accent);
  white-space: nowrap;
}
.notice.warning {
  border-color: #e8c68f42;
  background: #e8c68f1a;
  color: var(--accent);
}
.notice.danger {
  border-color: #ff9d9245;
  background: #ff9d9212;
  color: var(--danger);
}
.welcome {
  margin-top: 22px;
  border: 1px solid var(--line);
  padding: 30px;
  background: var(--panel);
}
.welcome h2 {
  font:
    26px Georgia,
    "Noto Sans SC",
    serif;
  letter-spacing: 1px;
}
.welcome p {
  color: var(--muted);
  font-size: 12px;
}
.welcome .button {
  margin-top: 10px;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 22px 0;
}
.kpi {
  padding: 21px 21px 17px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  position: relative;
  min-height: 145px;
  overflow: hidden;
}
.kpi.featured {
  border-top: 2px solid var(--accent);
  background: linear-gradient(130deg, var(--raised), var(--panel) 65%);
}
.kpi-label {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
}
.kpi-label span {
  font-size: 12px;
  white-space: nowrap;
  opacity: 0.75;
}
.kpi-value {
  font: 27px/1.5 var(--mono);
  letter-spacing: -1px;
  margin: 14px 0 13px;
  white-space: nowrap;
}
.kpi-value small {
  font: 12px var(--mono);
  letter-spacing: 0;
  color: var(--muted);
  margin-left: 8px;
}
.kpi-value.compact {
  font-size: 19px;
  letter-spacing: -0.5px;
}
.kpi-foot {
  font-size: 12px;
  color: var(--muted);
  white-space: normal;
}
/* 口径默认折叠，避免长覆盖说明撑高整排卡片；展开时保留完整文本。 */
.metric-details {
  min-width: 0;
  margin-top: 8px;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.metric-details summary {
  color: var(--muted);
  cursor: pointer;
}
.metric-details .kpi-foot {
  margin: 8px 0 0;
}
.two-column {
  display: grid;
  grid-template-columns: 1.08fr 1fr;
  gap: 18px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 22px;
  margin-bottom: 20px;
  min-width: 0;
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 18px;
}
.panel-heading h2 {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
  letter-spacing: 0.4px;
}
.panel-heading > span:not(.tag) {
  font-size: 12px;
  color: var(--muted);
}
.tag {
  display: inline-block;
  border: 1px solid #7f5440;
  padding: 3px 8px;
  color: #e3cec3;
  font-size: 12px;
  white-space: nowrap;
  border-radius: 3px;
}
.position-compare {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 10px 0 22px;
}
.position-compare > div > span {
  color: var(--muted);
  font-size: 12px;
}
.position-compare strong {
  display: block;
  font: 25px var(--mono);
  margin-top: 14px;
}
.position-compare > span {
  color: #dfbda6;
}
.position-compare small {
  margin-left: 8px;
  font-size: 12px;
  color: var(--muted);
}
.position-detail {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 0;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.position-detail b {
  font-family: var(--mono);
  font-weight: 400;
  color: var(--text);
  margin-left: 8px;
}
.key-values {
  margin: 8px 0 0;
}
.key-values > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid #4d302780;
}
.key-values > div:last-child {
  border-bottom: 0;
}
.key-values dt {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.key-values dd {
  font: 12px/1.8 var(--mono);
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
  min-width: 0;
}
.key-values dd small {
  font-size: 12px;
  color: var(--muted);
}
.key-values.large > div {
  padding: 18px 0;
}
.key-values.large dd {
  font-size: 17px;
}
.up {
  color: var(--up) !important;
}
.down {
  color: var(--down) !important;
}
.method-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.9;
  margin: 15px 0;
}
.table-wrap {
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  white-space: nowrap;
  text-align: left;
}
th {
  font-weight: 400;
  color: var(--muted);
  font-size: 12px;
  padding: 12px 13px;
  background: var(--deep);
  border-bottom: 1px solid var(--line-soft);
}
td {
  padding: 14px 13px;
  border-bottom: 1px solid #4d302780;
  font-family: var(--mono);
}
tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: var(--raised);
}
td small {
  font-size: 12px;
  color: var(--muted);
}
.sub {
  display: block;
  margin-top: 3px;
}
.side {
  font-size: 12px;
}
.mono {
  font-family: var(--mono);
}
.empty {
  text-align: center;
  color: var(--muted);
  font: 12px/1.8 var(--sans);
  padding: 50px 20px !important;
}
.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
}
.pagination > span {
  margin-right: auto;
}
.chart {
  height: 300px;
  min-height: 200px;
  width: 100%;
}
.chart.short {
  height: 240px;
}
.chart .empty {
  padding: 80px 0 !important;
}
.inline {
  display: flex;
  gap: 8px;
  align-items: center;
}
.inline input {
  font-size: 12px;
  width: 230px;
}
.checkbox {
  display: flex;
  gap: 9px;
  align-items: center;
  font-size: 12px;
}
.checkbox input {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
}
.working-row {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 12px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.working-row button {
  margin-left: auto;
}
details {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}
summary {
  cursor: pointer;
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12px/1.8 var(--mono);
  color: #e4d3c9;
  border: 1px solid var(--line-soft);
  padding: 14px;
  max-height: 62vh;
  overflow: auto;
  background: var(--deep);
}
footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding: 20px 0 24px;
  margin-top: 12px;
}
footer > span:first-child {
  font: 12px var(--mono);
  letter-spacing: 1.5px;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #2a120ac9;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(6px);
}
.modal {
  width: 480px;
  max-width: 100%;
  max-height: 92vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 26px;
  box-shadow: 0 30px 100px #0008;
}
.modal.wide {
  width: 800px;
}
.modal form > label:not(.checkbox) {
  display: block;
  margin: 20px 0;
}
.modal label > input:not([type="checkbox"]) {
  display: block;
  width: 100%;
  margin: 8px 0;
}
.modal label small {
  font-size: 12px;
  display: block;
  line-height: 1.8;
}
.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-top: 25px;
}
.modal pre {
  margin-bottom: 0;
}
.dashboard-kpis {
  margin: 20px 0 18px;
}
.dashboard-kpis .kpi {
  min-height: 132px;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
  margin-bottom: 24px;
}
.dashboard-card {
  grid-column: span 4;
  margin-bottom: 0;
  padding: 20px;
  overflow: hidden;
}
.dashboard-card.card-wide {
  grid-column: span 8;
}
.dashboard-grid > .dashboard-card.card-full {
  grid-column: 1 / -1;
}
.dashboard-card .panel-heading {
  gap: 10px;
  margin-bottom: 20px;
}
.dashboard-card .panel-heading h2 {
  display: flex;
  gap: 10px;
  align-items: center;
}
.card-index {
  font: 12px var(--mono);
  color: var(--accent);
  opacity: 0.65;
}
.card-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.signal-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 4px 0 18px;
}
.signal-metrics > div > span,
.trade-metrics > div > span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.signal-metrics strong {
  display: block;
  font: 26px/1.5 var(--mono);
  margin: 7px 0 4px;
}
.signal-metrics small {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.signal-scale {
  position: relative;
  height: 5px;
  background: var(--raised);
  border-radius: 3px;
}
.signal-scale > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.3s ease;
}
.signal-scale > i {
  position: absolute;
  left: 50%;
  top: -3px;
  width: 2px;
  height: 11px;
  background: var(--text);
}
.scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin: 9px 0 10px;
}
.compact-values > div {
  padding: 10px 0;
  gap: 12px;
}
.dashboard-card .position-compare {
  padding: 5px 0 22px;
}
.dashboard-card .position-compare strong {
  font-size: 23px;
}
.health-summary {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 4px 0 12px;
}
.health-summary strong {
  font-size: 16px;
  font-weight: 500;
}
.health-summary > .tag {
  margin-left: auto;
}
.status-dot {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.status-dot.observed {
  background: var(--blue);
  box-shadow: 0 0 0 4px #9dc4e61f;
}
.health-alert {
  border-top: 1px solid #e8c68f42;
  padding-top: 12px;
  margin-top: 12px;
  color: var(--accent);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.health-alert p {
  margin: 7px 0 0;
}
.health-alert small {
  color: var(--muted);
}
.trade-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin: 6px 0 0;
}
.trade-metrics strong {
  display: block;
  font: 22px/1.4 var(--mono);
  margin-top: 6px;
  overflow-wrap: anywhere;
}
.trade-metrics small {
  margin-left: 5px;
  font: 12px var(--mono);
  color: var(--muted);
}
/* 摘要、口径折叠与完整交易分析入口放到理论盈亏右侧，占右下网格位，收紧交易概况高度。 */
.trade-aside {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: space-between;
  border-left: 1px solid var(--line);
  padding-left: 16px;
  min-width: 0;
}
.trade-aside .method-note {
  margin: 0;
  line-height: 1.7;
}
.trade-aside .metric-details {
  margin-top: 0;
}
.trade-aside .health-alert {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.trade-aside .text-button {
  align-self: flex-start;
}
.dashboard-chart {
  height: 235px;
}
.indicator-overview {
  height: 260px;
}
.pnl-card .key-values dt {
  white-space: normal;
  max-width: 64%;
}
.pnl-card .key-values dd {
  flex-shrink: 0;
}
.recent-orders th,
.recent-orders td {
  padding: 12px 9px;
}
.activity-list {
  display: grid;
}
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  width: 100%;
  padding: 13px 0;
  border: 0;
  border-bottom: 1px solid #4d302780;
  background: transparent;
}
.activity-item:hover .activity-title {
  color: var(--accent);
}
.activity-marker {
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--blue);
  margin-top: 6px;
}
.activity-content {
  flex: 1;
  min-width: 0;
}
.activity-title {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 12px;
}
.activity-title time {
  color: var(--muted);
  font: 12px/1.8 var(--mono);
}
.activity-summary {
  display: block;
  color: var(--muted);
  font: 12px/1.8 var(--mono);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-top: 4px;
}
.archive-link {
  margin-top: 16px;
}
@media (max-width: 1320px) and (min-width: 801px) {
  .dashboard-grid > .dashboard-card {
    grid-column: span 6;
  }
  .dashboard-grid > .card-wide {
    grid-column: span 12;
  }
  .dashboard-grid .recent-orders {
    grid-column: span 12;
  }
}
.trades-kpis .kpi-value {
  white-space: normal;
  overflow-wrap: anywhere;
}
/* 交易统计独立五列，仅在手机端沿用双列；不改变账户与策略的网格。 */
@media (min-width: 801px) {
  .kpi-grid.trades-kpis {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
  }
  .trades-kpis .kpi {
    min-width: 0;
    padding: 18px 12px;
  }
  .trades-kpis .kpi-value {
    font-size: clamp(18px, 1.6vw, 27px);
    letter-spacing: -0.6px;
  }
  .trades-kpis .kpi-value small {
    margin-left: 4px;
  }
}
@media (max-width: 800px) {
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  .dashboard-grid > .dashboard-card {
    grid-column: 1;
  }
  .dashboard-card {
    padding: 18px;
  }
  .dashboard-kpis .kpi {
    min-height: 135px;
  }
}
@media (min-width: 1600px) {
  .workspace {
    padding: 36px 28px 0;
  }
  .kpi-value {
    font-size: 34px;
  }
}
@media (max-width: 1180px) {
  .sidebar {
    width: 194px;
    padding-inline: 14px;
  }
  main {
    margin-left: 194px;
  }
  .workspace {
    padding: 28px 24px 0;
  }
  .topbar {
    padding: 0 24px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .two-column {
    grid-template-columns: 1fr 1fr;
  }
  .refresh-label {
    margin-left: 0;
  }
}
@media (max-width: 800px) {
  .sidebar {
    position: relative;
    width: auto;
    inset: auto;
    padding: 16px 20px;
    display: block;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand {
    padding: 0;
    gap: 10px;
  }
  .brand b {
    font-size: 35px;
  }
  .brand > span {
    font-size: 21px;
  }
  .nav-caption,
  .sidebar-bottom {
    display: none;
  }
  nav {
    display: flex;
    gap: 4px;
    overflow: auto;
    margin-top: 15px;
  }
  nav button {
    white-space: nowrap;
    padding: 9px 12px;
    font-size: 12px;
    gap: 5px;
  }
  nav button > span,
  nav button > i {
    display: none;
  }
  main {
    margin-left: 0;
  }
  .topbar {
    height: 56px;
    padding: 0 20px;
  }
  .workspace {
    padding: 24px 20px 0;
  }
  .page-heading {
    align-items: flex-start;
    gap: 10px;
  }
  .page-heading p {
    max-width: 360px;
  }
  .heading-clock {
    padding-top: 9px;
  }
  .two-column {
    grid-template-columns: 1fr;
  }
  .kpi-grid {
    gap: 12px;
    margin-top: 18px;
  }
  .kpi {
    padding: 16px;
  }
  .filterbar {
    gap: 12px;
  }
  .filterbar select {
    max-width: 200px;
  }
  .panel {
    padding: 18px;
  }
  .notice {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 7px;
  }
  .panel-heading {
    flex-wrap: wrap;
  }
  .kpi-value {
    font-size: 25px;
  }
  h1 {
    font-size: 25px;
  }
  .mode-label {
    margin-left: auto;
  }
  .refresh-label {
    margin-left: auto;
  }
  .inline input {
    width: 200px;
  }
}
@media (max-width: 460px) {
  .workspace {
    padding-inline: 14px;
  }
  .topbar {
    padding-inline: 14px;
  }
  .topbar > div:first-child {
    display: none;
  }
  .top-actions {
    justify-content: space-between;
    width: 100%;
  }
  .heading-clock {
    display: none;
  }
  .kpi-value {
    font-size: 21px;
    letter-spacing: -0.8px;
  }
  .kpi-label {
    flex-wrap: wrap;
  }
  .filterbar label {
    gap: 7px;
  }
  .filterbar select {
    max-width: 210px;
    padding: 8px;
  }
  .position-compare strong {
    font-size: 22px;
  }
  .inline input {
    width: 185px;
  }
  .modal {
    padding: 20px;
  }
  nav button {
    padding-inline: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* 账户级总览：资产单次计量，子策略并列，不依赖当前合约选择。 */
.portfolio {
  display: grid;
  gap: 22px;
  padding-bottom: 28px;
}
.portfolio .panel {
  margin: 0;
  min-width: 0;
}
.portfolio-scope {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--accent);
  border-left: 1px solid var(--line);
  padding-left: 16px;
  font-size: 12px;
}
.portfolio-scope b {
  font: 16px var(--mono);
}
.portfolio-command {
  display: grid;
  grid-template-columns: minmax(250px, .72fr) minmax(0, 2.28fr);
  gap: 18px;
  align-items: stretch;
}
.portfolio-capital-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.portfolio-command > .panel,
.portfolio-capital-stack > .panel {
  padding: 16px;
}
.portfolio-capital-stack > .portfolio-breakdown {
  flex: 1;
}
.portfolio-equity {
  border-top: 2px solid var(--accent);
  background: linear-gradient(115deg, var(--raised), var(--panel) 72%);
}
.portfolio-kicker {
  color: var(--accent);
  font: 12px var(--mono);
  letter-spacing: 1.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.portfolio-equity h2 {
  margin: 12px 0 6px;
  font-size: 16px;
}
.portfolio-equity h2 > span {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
  margin-left: 12px;
}
.equity-number {
  font: clamp(28px, 2.2vw, 40px)/1.3 var(--mono);
  letter-spacing: -1.5px;
  overflow-wrap: anywhere;
}
.equity-number small {
  display: inline-block;
  white-space: nowrap;
  color: var(--accent);
  font: 13px var(--mono);
  letter-spacing: 0;
  margin-left: 10px;
}
.equity-secondary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.equity-secondary span,
.strategy-financials span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
/* 窄卡片内的小字也必须保持 12px，避免可读性回退 */
.equity-secondary small {
  font-size: 12px;
}
.equity-secondary strong {
  display: block;
  font: 20px/1.6 var(--mono);
  overflow-wrap: anywhere;
}
/* 持仓市值/浮盈的覆盖说明：未知实例不补零 */
.equity-coverage {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.equity-exposure-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}
.equity-source {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  border-top: 1px solid var(--line-soft);
  margin-top: 12px;
  padding-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
/* 账户卡片内的凯利分配摘要：点击打开资金与凯利明细 */
.equity-kelly {
  border-top: 1px solid var(--line-soft);
  margin-top: 12px;
  padding-top: 12px;
}
.equity-kelly-button {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  background: var(--deep);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
}
.equity-kelly-button:hover {
  border-color: var(--line);
}
.equity-kelly-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .8px;
}
.equity-kelly-heading b {
  font-weight: 500;
  letter-spacing: 0;
}
.equity-kelly-heading b.published { color: var(--down); }
.equity-kelly-heading b.pending { color: var(--accent); }
.equity-kelly-heading b.neutral { color: var(--muted); }
.equity-kelly-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.equity-kelly-total strong {
  font: clamp(22px, 1.8vw, 28px)/1.3 var(--mono);
  color: var(--accent);
  overflow-wrap: anywhere;
}
.equity-kelly-total small,
.equity-kelly-coverage,
.equity-kelly-extremes i {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}
.equity-kelly-extremes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 10px;
}
.equity-kelly-extremes > span {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 6px;
  min-width: 0;
}
.equity-kelly-extremes b,
.equity-kelly-extremes strong {
  font: 13px/1.6 var(--mono);
}
.equity-kelly-extremes strong { color: var(--text); }
.equity-kelly-more {
  color: var(--accent);
  font-size: 12px;
}
.equity-kelly-more::after { content: " ↗"; }
.portfolio-status {
  display: flex;
  flex-direction: column;
}
.running { --state-color: var(--down); }
.paused, .initializing, .stopping { --state-color: var(--accent); }
.replaying, .observing { --state-color: #80b7d8; }
.closing { --state-color: #efab75; }
.stopped, .ended { --state-color: #aab0bd; }
.attention, .blocked { --state-color: var(--danger); }
.unknown { --state-color: var(--muted); }
.portfolio-status .timeline-heading {
  gap: 8px 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.timeline-heading h2 {
  margin: 0;
}
.timeline-heading h2 small {
  color: var(--muted);
  font-weight: 400;
  margin-left: 8px;
}
.timeline-clock {
  color: var(--accent);
  font: 12px/1.8 var(--mono);
  text-align: right;
}
.timeline-clock small {
  margin-left: 4px;
  color: var(--muted);
}
.timeline-scroll {
  flex: 1 0 auto;
  height: 560px; /* 实际高度由拖动条控制并写入 localStorage */
  min-height: 220px;
  max-height: 80vh;
  overflow: auto;
  scrollbar-color: var(--line) var(--deep);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--deep);
}
.timeline-resizer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 22px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  cursor: ns-resize;
  touch-action: none;
  border-top: 1px dashed var(--line-soft);
  user-select: none;
}
.timeline-resizer i {
  width: 34px;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
}
.timeline-resizer:hover,
.timeline-resizer:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}
.timeline-resizer:hover i,
.timeline-resizer:focus-visible i {
  background: var(--accent);
}
.cycle-timeline {
  min-width: 650px;
  --identity-width: 168px;
}
.timeline-axis-row,
.timeline-row {
  display: grid;
  grid-template-columns: var(--identity-width) minmax(0, 1fr);
}
.timeline-axis-row {
  height: 38px;
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--deep);
}
.timeline-axis-label {
  padding: 9px 12px;
  color: var(--muted);
  font-size: 12px;
  border-right: 1px solid var(--line-soft);
}
.timeline-axis,
.timeline-lane {
  position: relative;
  margin-inline: 22px;
  min-width: 0;
}
.timeline-tick {
  position: absolute;
  top: 1px;
  transform: translateX(-50%);
  white-space: nowrap;
  text-align: center;
  font: 12px/1.5 var(--mono);
  color: var(--muted);
}
.timeline-tick b,
.timeline-tick small {
  display: block;
}
.timeline-tick b {
  font-weight: 500;
  color: var(--text);
}
.timeline-row {
  min-height: 62px;
  border-top: 1px solid var(--line-soft);
}
.timeline-identity {
  padding: 8px 12px;
  border-right: 1px solid var(--line-soft);
  min-width: 0;
}
.timeline-identity > div {
  display: flex;
  align-items: center;
  gap: 6px;
}
.timeline-identity i,
.timeline-legend i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--state-color);
  flex-shrink: 0;
}
.timeline-identity strong {
  font: 14px var(--mono);
}
.timeline-state {
  margin-left: auto;
  font-size: 12px;
  color: var(--state-color);
}
.timeline-cycle-id {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.timeline-grid,
.timeline-grid i {
  position: absolute;
  inset-block: 0;
  pointer-events: none;
}
.timeline-grid {
  inset-inline: 0;
}
.timeline-grid i {
  width: 1px;
  background: #dcc6ba14;
}
.timeline-now {
  position: absolute;
  inset-block: 0;
  width: 1px;
  background: var(--accent);
  box-shadow: 0 0 5px #e8c68f20;
  z-index: 2;
  pointer-events: none;
}
.cycle-window {
  position: absolute;
  top: 9px;
  height: 23px;
  border: 1px solid var(--state-color);
  border-radius: 16px;
  background: color-mix(in srgb, var(--state-color) 14%, var(--deep));
  /* 以进度条自身宽度为容器，窄条的完整摘要仍可悬停查看。 */
  container-type: inline-size;
}
.cycle-window.pending {
  border-style: dashed;
}
.cycle-window.ended {
  border-style: double;
}
.cycle-elapsed {
  height: 100%;
  border-radius: inherit;
  background: color-mix(in srgb, var(--state-color) 43%, transparent);
}
/* 进度条内部：左侧时间进度，右侧目标、实际持仓与浮盈。 */
.cycle-bar-content {
  position: absolute;
  inset: 1px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
  pointer-events: none;
}
.cycle-bar-label {
  min-width: 0;
  overflow: hidden;
  font: 12px/19px var(--mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 持仓与浮盈保持在条内，不另占时间轴行。 */
.cycle-facts {
  display: flex;
  flex: 0 1 auto;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font: 12px/19px var(--mono);
  white-space: nowrap;
  pointer-events: auto;
}
.cycle-facts > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cycle-facts b {
  color: var(--text);
  font-weight: 500;
}
/* 窄周期条保留进度和悬停信息，不把摘要移出条外。 */
@container (max-width: 360px) {
  .cycle-facts {
    display: none;
  }
}
.cycle-position {
  position: absolute;
  top: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--state-color);
  box-shadow: 0 0 0 3px var(--deep);
  transform: translateX(-50%);
}
.cycle-range {
  position: absolute;
  top: 38px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font: 12px var(--mono);
  color: var(--muted);
}
.cycle-range b {
  color: var(--state-color);
  font-weight: 400;
}
.cycle-empty {
  position: absolute;
  inset: 9px 0 auto;
  height: 23px;
  border: 1px dashed var(--state-color);
  border-radius: 16px;
  background: color-mix(in srgb, var(--state-color) 10%, transparent);
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
  padding: 0 10px;
  font-size: 12px;
  color: var(--state-color);
}
.cycle-empty span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cycle-empty > b {
  font-weight: 400;
  flex-shrink: 0;
  margin-left: auto;
}
.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.timeline-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.timeline-legend .now-legend {
  color: var(--accent);
}
.portfolio-status .method-note {
  margin: 4px 0 0;
}
.portfolio-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.portfolio-value {
  font: 28px/1.4 var(--mono);
  margin: 16px 0 8px;
  letter-spacing: -0.6px;
  overflow-wrap: anywhere;
}
.coverage-label {
  font-size: 12px;
  color: var(--muted);
}
.portfolio-warning {
  color: var(--accent);
}
.portfolio-section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 10px 0 18px;
}
.portfolio-section-heading h2 {
  font-size: 20px;
  margin: 5px 0 0;
}
.portfolio-section-heading h2 small {
  color: var(--muted);
  font-weight: 400;
  margin-left: 10px;
}
.portfolio-section-heading p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.fleet-heading-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
}
.fleet-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.view-switch {
  display: inline-flex;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  overflow: hidden;
}
.view-switch button {
  padding: 6px 14px;
  border: 0;
  background: var(--deep);
  color: var(--muted);
  font-size: 12px;
}
.view-switch button + button {
  border-left: 1px solid var(--line-soft);
}
.view-switch button:hover {
  color: var(--text);
}
.view-switch button.selected {
  background: var(--raised);
  color: var(--accent);
}
.strategy-fleet {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 350px), 1fr));
  gap: 18px;
}
.portfolio-strategies {
  /* 表格有 min-width，父级必须允许收缩，否则会把整页撑出横向滚动。 */
  min-width: 0;
}
.strategy-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: var(--panel);
}
.strategy-table {
  width: 100%;
  min-width: 1640px;
  border-collapse: collapse;
  font-size: 12px;
}
.strategy-table caption {
  padding: 10px 14px;
  color: var(--muted);
  text-align: left;
  font-size: 12px;
}
.strategy-table th,
.strategy-table td {
  padding: 9px 12px;
  border-top: 1px solid var(--line-soft);
  text-align: right;
  vertical-align: top;
  white-space: nowrap;
}
.strategy-table thead th {
  background: var(--deep);
  color: var(--muted);
  font-weight: 500;
}
.strategy-table th[scope="row"] {
  text-align: left;
  font-weight: 400;
}
.strategy-table td small,
.strategy-table th[scope="row"] small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}
.strategy-table [data-testid="runtime-status"] {
  min-width: 210px;
  max-width: 320px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.strategy-table .table-mono {
  font-family: var(--mono);
}
.strategy-table .table-strategy {
  display: flex;
  align-items: center;
  gap: 10px;
}
.strategy-table .table-strategy b {
  font-weight: 500;
}
.strategy-table tbody tr.paused .fleet-state { color: var(--accent); }
.strategy-table tbody tr.attention .fleet-state { color: var(--danger); }
.strategy-table tbody tr.unknown .fleet-state { color: var(--muted); }
.strategy-table .kelly-published { color: var(--down); }
.strategy-table .kelly-pending { color: var(--accent); }
.strategy-table .kelly-neutral { color: var(--muted); }
.strategy-tile {
  display: flex;
  flex-direction: column;
}
.strategy-price {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px 12px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
}
.strategy-price strong {
  margin-left: 4px;
  color: var(--text);
  font: 15px/1.5 var(--mono);
}
.strategy-price small {
  color: var(--muted);
  font-size: 12px;
}
.strategy-tile-heading,
.strategy-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}
.strategy-tile-heading {
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}
.strategy-identity {
  min-width: 0;
}
.coin-monogram {
  display: grid;
  place-items: center;
  min-width: 42px;
  height: 42px;
  padding: 0 5px;
  border: 1px solid #e8c68f50;
  background: var(--raised);
  color: var(--accent);
  font: 14px var(--mono);
}
.strategy-identity h3 {
  font: 15px/1.6 var(--mono);
  margin: 0;
  overflow-wrap: anywhere;
}
.strategy-identity small {
  color: var(--muted);
}
.fleet-state {
  color: var(--state-color);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.fleet-state::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.runtime-detail { margin-top: 14px; }
.runtime-detail p { margin: 0 0 4px; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.runtime-detail small { color: var(--muted); font: 12px/1.6 var(--mono); }
/* 入场条件：只用 Trader 已发布的策略/指标快照解释“为何还没开新周期”，不展示租约。 */
.entry-gate {
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 2px solid var(--line);
  background: var(--deep);
}
.entry-gate.ready { border-left-color: var(--down); }
.entry-gate.pending { border-left-color: var(--blue); }
.entry-gate.cooling,
.entry-gate.waiting { border-left-color: var(--accent); }
.entry-gate.blocked { border-left-color: var(--danger); }
.entry-gate-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.entry-gate-heading b { color: var(--text); font-weight: 500; }
.entry-gate-reason { margin: 6px 0 0; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.entry-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.entry-checks li {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
  padding: 1px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--deep);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.entry-checks li b { font-family: var(--mono); font-weight: 500; color: var(--text); }
/* 达标项用绿色 tag；未达标保持默认色，不额外着色。 */
.entry-checks li.met { border-color: #8ed3b866; background: #8ed3b81f; }
.entry-checks li.met b { color: var(--down); }
.entry-checks li.unknown { border-style: dashed; }
.entry-state { font-weight: 500; }
.entry-state.ready { color: var(--down); }
.entry-state.pending { color: var(--blue); }
.entry-state.cooling,
.entry-state.waiting { color: var(--accent); }
.entry-state.blocked { color: var(--danger); }
.strategy-table .table-entry {
  width: 420px;
  min-width: 420px;
  text-align: left;
  white-space: nowrap;
  overflow-wrap: normal;
}
/* 入场条件 tag 固定一行，列宽已加大；只有原因长句允许在单元格内换行。 */
.strategy-table .entry-checks { margin: 4px 0 0; justify-content: flex-start; flex-wrap: nowrap; }
.strategy-table .table-entry small { white-space: normal; }
.runtime-panel { margin-bottom: 20px; }
.runtime-panel .method-note { margin-bottom: 0; }
.strategy-control {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
  margin: 20px 0;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
.strategy-control > span,
.strategy-control small {
  color: var(--muted);
}
.strategy-control small {
  margin-left: auto;
}
.strategy-positions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 22px;
}
.strategy-positions dt {
  color: var(--muted);
  font-size: 12px;
}
.strategy-positions dt small {
  display: block;
  font: 12px/1.8 var(--mono);
}
.strategy-positions dd {
  margin: 5px 0 0;
  font: 18px/1.5 var(--mono);
  overflow-wrap: anywhere;
}
.strategy-financials {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 14px;
  background: var(--deep);
}
.strategy-financials strong {
  font: 20px/1.8 var(--mono);
  overflow-wrap: anywhere;
}
.strategy-note {
  font-size: 12px;
  line-height: 1.8;
  margin: 16px 0 20px;
  overflow-wrap: anywhere;
}
.strategy-tile-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.strategy-tile-footer > span {
  font-size: 12px;
  color: var(--muted);
}
.portfolio-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}
/* 预算只滚动列表，保留标题和口径说明，避免实例增多撑高页面。 */
.budget-scroll {
  max-height: 260px;
  overflow: auto;
  scrollbar-gutter: stable;
  scrollbar-color: var(--line) var(--deep);
  padding-right: 8px;
}
.budget-row {
  margin: 12px 0;
}
.budget-row > div:first-child {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font: 14px/1.8 var(--mono);
}
.budget-row small {
  color: var(--muted);
  margin-left: 8px;
}
.budget-track {
  height: 5px;
  background: var(--deep);
  margin-top: 8px;
}
.budget-track > span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.portfolio-breakdown .key-values > div {
  flex-wrap: wrap;
  gap: 4px 12px;
}
.portfolio-breakdown .key-values dt {
  min-width: 0;
  white-space: normal;
}
.portfolio-breakdown .key-values dd {
  flex-shrink: 0;
}
.portfolio-attention ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.portfolio-attention li {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 3fr;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.portfolio-attention li b {
  font-family: var(--mono);
  color: var(--accent);
}
.portfolio-attention li span {
  color: var(--muted);
}
.portfolio-method {
  margin-top: 18px;
}
.kelly-panel {
  margin-bottom: 22px;
  border-top: 2px solid var(--accent);
}
.kelly-panel .panel-heading h2 { margin-bottom: 4px; }
.kelly-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid currentColor;
  font-size: 12px;
  border-radius: 3px;
}
.kelly-status.published, .kelly-mini.published .kelly-mini-heading b { color: var(--down); }
.kelly-status.pending, .kelly-status.attention { color: var(--accent); }
.kelly-status.neutral, .kelly-mini.neutral { color: var(--muted); }
.kelly-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  margin: 20px 0;
}
.kelly-metrics > div { background: var(--deep); padding: 18px; min-width: 0; }
.kelly-metrics span, .kelly-metrics small { display: block; color: var(--muted); font-size: 12px; }
.kelly-metrics strong { display: block; font: 29px/1.6 var(--mono); color: var(--accent); overflow-wrap: anywhere; }
.kelly-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
.kelly-detail-grid > div { min-width: 0; }
.kelly-panel .key-values dd { overflow-wrap: anywhere; }
.kelly-audit { margin-top: 14px; font-size: 12px; color: var(--muted); }
.kelly-audit p { overflow-wrap: anywhere; }
.kelly-mini { padding: 14px 0 0; margin-top: 16px; border-top: 1px solid var(--line-soft); }
.kelly-mini-heading, .kelly-mini-value { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kelly-mini-heading { font-size: 12px; color: var(--muted); }
.kelly-mini-heading > span { letter-spacing: .8px; }
.kelly-mini-heading b { color: var(--accent); font-weight: 500; }
.kelly-mini-value { margin-top: 8px; }
.kelly-mini-value > strong { font: 24px/1.5 var(--mono); color: var(--accent); }
.kelly-mini-value > span, .kelly-mini p { font-size: 12px; color: var(--muted); }
.kelly-mini-value b { font-family: var(--mono); color: var(--text); }
.kelly-mini p { margin: 6px 0 0; overflow-wrap: anywhere; }
@media (max-width: 700px) {
  .kelly-detail-grid, .kelly-metrics { grid-template-columns: minmax(0, 1fr); }
  .kelly-metrics > div { padding: 14px 16px; }
  .kelly-metrics strong { font-size: 25px; }
}
/* 资金与凯利明细弹窗：汇总四项 + 逐子策略表；窄屏横向滚动，不压缩字号。 */
.modal.capital-modal { width: 900px; }
.capital-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  margin: 18px 0;
}
.capital-summary > div {
  background: var(--deep);
  padding: 14px;
  min-width: 0;
}
.capital-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.capital-summary strong {
  display: block;
  font: 20px/1.5 var(--mono);
  color: var(--accent);
  overflow-wrap: anywhere;
}
.capital-summary strong small {
  margin-left: 5px;
  color: var(--muted);
  font-size: 12px;
}
.capital-summary > div > small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}
.capital-table-wrap { overflow-x: auto; }
.capital-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 12px;
}
.capital-table caption {
  padding-bottom: 8px;
  color: var(--muted);
  text-align: left;
  font-size: 12px;
}
.capital-table th,
.capital-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
  white-space: nowrap;
}
.capital-table thead th {
  color: var(--muted);
  font-weight: 500;
}
.capital-table th[scope="row"] {
  text-align: left;
  font-weight: 400;
}
.capital-table th[scope="row"] b { font-weight: 500; }
.capital-table th[scope="row"] small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.capital-table tbody tr.neutral td,
.capital-table tbody tr.neutral th { color: var(--muted); }
.capital-table tbody tr.pending td:nth-child(3) { color: var(--accent); }
.capital-table tbody td[colspan] {
  text-align: left;
  color: var(--muted);
}
.capital-modal .method-note { margin-top: 14px; }
@media (max-width: 900px) {
  .capital-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .capital-summary { grid-template-columns: minmax(0, 1fr); }
}
.param-block {
  margin-top: 14px;
}
.param-block .method-note {
  margin-top: 0;
}
@media (max-width: 1100px) {
  .portfolio-command {
    grid-template-columns: minmax(0, 1fr);
  }
  .portfolio-metric {
    padding: 18px;
  }
  .portfolio-value {
    font-size: 23px;
  }
}
@media (max-width: 600px) {
  .portfolio {
    gap: 16px;
  }
  .portfolio-section-heading {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .fleet-heading-side {
    align-items: flex-start;
  }
  .portfolio-command,
  .portfolio-bottom,
  .portfolio-metrics {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  .portfolio-metric .portfolio-value {
    margin-top: 10px;
    font-size: 28px;
  }
  .portfolio-metric .method-note {
    margin-bottom: 0;
  }
  .equity-number {
    font-size: 36px;
  }
  .portfolio-section-heading {
    display: block;
  }
  .portfolio-section-heading p {
    margin-top: 8px;
  }
  .portfolio-attention li {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .portfolio-scope {
    padding-left: 10px;
    gap: 8px;
  }
}
/* ===== 策略管理：独立鉴权入口、策略卡与命令回执 ===== */
/* 管理令牌输入区：单列、不与其他监控表单混排。 */
.mgmt-gate {
  max-width: 760px;
}
.mgmt-gate-form label {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.mgmt-gate-form input {
  display: block;
  width: 100%;
  max-width: 420px;
  margin: 8px 0;
  font-size: 13px;
}
.mgmt-gate-form small {
  display: block;
  line-height: 1.8;
}
.mgmt-gate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.mgmt-session .inline {
  flex-wrap: wrap;
  justify-content: flex-end;
}
/* 策略卡：可用性、真实运行态与控制意图分区展示，窄屏单列。 */
.mgmt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
  margin-bottom: 20px;
}
.mgmt-card {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
/* 不可操作的策略整体降权，但文字仍保持可读。 */
.mgmt-card.is-blocked {
  border-color: #7f5440;
  background: linear-gradient(160deg, #2c280e, #211d07);
}
.mgmt-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}
.mgmt-card-heading h3 {
  margin: 4px 0 6px;
  font: 17px/1.3 var(--mono);
  letter-spacing: 0.4px;
}
.mgmt-card-heading small {
  color: var(--muted);
}
.mgmt-availability {
  flex: none;
  border: 1px solid #7f5440;
  border-radius: 3px;
  padding: 3px 8px;
  font-size: 12px;
  white-space: nowrap;
}
.mgmt-availability.ok {
  border-color: #8ed3b855;
  color: var(--down);
}
.mgmt-availability.blocked {
  border-color: #ff9d9245;
  color: var(--danger);
}
.mgmt-facts {
  margin-top: 6px;
}
.mgmt-facts dd b {
  display: block;
  font-weight: 400;
}
.mgmt-facts dd small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}
.mgmt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
/* 平仓并停用风险最高：仅靠描边与文字色区分，不用整块红底。 */
.mgmt-actions .button.mgmt-danger {
  border-color: #ff9d9270;
  color: var(--danger);
}
.mgmt-pending {
  border-left: 2px solid var(--accent);
  padding-left: 10px;
  margin-bottom: 0;
}
.mgmt-last {
  margin-bottom: 0;
}
/* 命令状态：与 queue/applied/processing/completed/rejected/expired 一一对应。 */
.mgmt-command {
  display: inline-block;
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 1px 7px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.mgmt-command.ok {
  border-color: #8ed3b855;
  color: var(--down);
}
.mgmt-command.active {
  border-color: #9dc4e655;
  color: var(--blue);
}
.mgmt-command.danger {
  border-color: #ff9d9245;
  color: var(--danger);
}
.mgmt-history td small {
  display: block;
  margin-top: 3px;
}
@media (max-width: 900px) {
  .mgmt-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 800px) {
  /* 手机端管理页顶部会话条换行，按钮不被挤压。 */
  .mgmt-session .panel-heading {
    align-items: flex-start;
  }
  .mgmt-session .inline {
    justify-content: flex-start;
  }
  .mgmt-actions .button {
    flex: 1 1 46%;
  }
}
@media (max-width: 460px) {
  /* 极窄屏操作按钮整行排列，避免误触相邻动作。 */
  .mgmt-actions .button {
    flex: 1 1 100%;
  }
  .mgmt-gate-form input {
    max-width: none;
  }
}
/* 策略状态页的全子策略表格：整行可点击打开详情弹窗 */
.clickable-row {
  cursor: pointer;
}
.clickable-row:hover {
  background: color-mix(in srgb, var(--line-soft) 42%, transparent);
}
.clickable-row .text-button {
  white-space: nowrap;
}

