:root {
  --app-bg: #f4f6fa;
  --panel: #f8fafc;
  --panel-strong: #ffffff;
  --input-bg: #ffffff;
  --line: #cbd3df;
  --line-soft: #e2e7ee;
  --text: #18212f;
  --muted: #56657a;
  --faint: #7f8b9e;
  --blue: #1967a3;
  --blue-soft: #d7e5f4;
  --green: #087f5b;
  --green-soft: #e2f2eb;
  --red: #b53c42;
  --red-soft: #f8e8e9;
  --yellow: #9a6b10;
  --sidebar-width: 0px;
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-width: 320px; margin: 0; background: var(--app-bg); color: var(--text); }
body { font-size: 13px; line-height: 1.4; }
button, input, select, textarea { font: inherit; }
button { min-height: 28px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 3px; background: #e7ecf3; color: var(--text); cursor: pointer; white-space: nowrap; }
button:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-soft); }
button:disabled { cursor: not-allowed; opacity: .48; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #5c98c8; outline-offset: 1px; }
input, select, textarea { border: 1px solid var(--line); border-radius: 3px; background: var(--input-bg); color: var(--text); }
input, select { min-height: 28px; padding: 3px 7px; }
textarea { display: block; width: 100%; min-height: 250px; padding: 9px; resize: vertical; font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; }
h1, h2, p { margin: 0; }
h1 { font-size: 21px; font-weight: 500; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 500; }

.app-shell { min-height: 100vh; }
.auth-gate { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: var(--app-bg); }
.auth-panel { width: min(100%, 380px); padding: 26px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel-strong); box-shadow: 0 8px 24px #1b2a3b18; }
.auth-panel h1 { margin-top: 10px; }
.auth-panel > p { margin-top: 7px; color: var(--muted); font-size: 12px; }
.auth-form { display: grid; gap: 8px; margin-top: 22px; }
.auth-form label { color: var(--muted); font-size: 12px; }
.auth-form input { width: 100%; min-height: 34px; }
.auth-form button { justify-self: start; margin-top: 5px; min-width: 100px; }
.auth-message { min-height: 18px; margin: 0; color: var(--red); font-size: 12px; }
.command-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 45px; padding: 7px 14px; border-bottom: 1px solid var(--line); background: var(--panel-strong); }
.command-main, .command-meta, .segmented, .hft-actions { display: flex; align-items: center; gap: 6px; }
.command-main { min-width: 0; flex-wrap: wrap; }
.command-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.paper-badge { padding: 4px 6px; color: var(--blue); font-weight: 500; }
.toolbar-label, .tab-status { color: var(--muted); }
.toolbar-separator, .meta-separator { color: var(--line); }
.toolbar-separator { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }
.command-primary { border-color: #86aac8; background: var(--blue-soft); color: #124f7b; }
.command-danger { color: var(--red); }
.segmented { gap: 0; }
.segmented button { border-radius: 0; margin-left: -1px; }
.segmented button:first-child { margin-left: 0; border-radius: 3px 0 0 3px; }
.segmented button:last-child { border-radius: 0 3px 3px 0; }
.segmented button.selected { border-color: #5e91ba; background: #bed8ef; color: #124f7b; }
.token-details { position: relative; margin-left: 8px; }
.token-details summary { color: var(--blue); cursor: pointer; }
.token-editor { position: absolute; z-index: 5; top: 25px; right: 0; display: flex; gap: 5px; padding: 8px; border: 1px solid var(--line); background: var(--panel-strong); box-shadow: 0 4px 12px #1b2a3b22; }
.token-editor input { width: 230px; }

.tab-bar { display: flex; align-items: center; gap: 8px; min-height: 43px; padding: 6px 14px; border-bottom: 1px solid var(--line); background: #eef2f7; overflow-x: auto; }
.tab-button { min-width: 108px; min-height: 30px; background: #e7ecf3; }
.tab-button.active { border-color: #5187b1; background: #bed8ef; color: #124f7b; }
.tab-status { margin-left: auto; padding-left: 10px; font-size: 12px; white-space: nowrap; }
.notice { min-height: 0; padding: 0 18px; color: var(--muted); }
.notice:not(:empty) { min-height: 31px; padding-top: 7px; }
.notice.error { color: var(--red); }
.notice.success { color: var(--green); }

.workspace { padding: 12px 14px 24px; }
.page { display: none; max-width: 1800px; margin: 0 auto; }
.page[hidden] { display: none !important; }
.page.active { display: block; }
.overview-page { display: grid; grid-template-columns: minmax(320px, 420px) minmax(560px, 1fr) minmax(260px, 320px); gap: 10px; align-items: start; }
.overview-page.active { display: grid; }
.gui-pane, .gui-group { border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }
.gui-pane { min-width: 0; padding: 12px; }
.config-pane, .manual-pane { min-height: 540px; overflow: auto; max-height: calc(100vh - 116px); }
.pane-heading, .page-heading, .workbench-heading, .group-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pane-heading { padding-bottom: 10px; border-bottom: 1px solid var(--line-soft); }
.pane-heading > span, .page-heading > span, .group-heading > span { color: var(--muted); font-size: 11px; }
.page-heading { min-height: 42px; padding: 0 2px 10px; border-bottom: 1px solid var(--line); }
.workbench-pane { min-width: 0; }
.workbench-heading { min-height: 48px; padding: 0 3px 9px; align-items: flex-start; }
.workbench-heading p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.paper-state { color: var(--blue); font-size: 12px; }
.inline-message { min-height: 20px; padding: 2px 3px; color: var(--muted); font-size: 12px; }
.inline-message.error { color: var(--red); }
.workbench-grid { display: grid; grid-template-columns: minmax(180px, .75fr) minmax(300px, 1.25fr); gap: 10px; }
.gui-group { min-width: 0; padding: 10px; }
.group-heading { min-height: 23px; margin-bottom: 7px; }
.group-heading strong { font-weight: 500; }
.heading-right { margin-left: auto; }
.group-note, .config-footnote, .market-copy { color: var(--muted); font-size: 11px; }
.group-note { margin-top: 7px; }
.rank-list { max-height: 255px; overflow: auto; border-top: 1px solid var(--line-soft); }
.rank-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 8px; align-items: center; min-height: 24px; border-bottom: 1px solid var(--line-soft); font: 12px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; }
.rank-row > span, .rank-row em { color: var(--muted); font-style: normal; }
.rank-row strong { overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.equity-chart { position: relative; height: 290px; border: 1px solid var(--line-soft); background: var(--panel-strong); color: var(--muted); overflow: hidden; }
.equity-chart svg { display: block; width: 100%; height: 100%; }
.chart-grid { stroke: #e2e7ee; stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-grid-vertical { stroke-dasharray: 3 4; }
.chart-axis { stroke: #aeb9c7; stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-label { fill: #68778b; font: 11px "Segoe UI", "Microsoft YaHei", sans-serif; }
.chart-current { fill: #1967a3; font: 500 12px "Segoe UI", "Microsoft YaHei", sans-serif; }
.chart-baseline { stroke: #9aa9b8; stroke-width: 1; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
.chart-baseline-label { fill: #7f8b9e; font: 11px "Segoe UI", "Microsoft YaHei", sans-serif; }
.equity-line { fill: none; stroke: #4f91bf; stroke-linejoin: round; stroke-linecap: round; stroke-width: 2; vector-effect: non-scaling-stroke; }
.equity-point { fill: #ffffff; stroke: #1967a3; stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-guide { stroke: #8bb0ce; stroke-dasharray: 3 3; stroke-width: 1; vector-effect: non-scaling-stroke; }

.config-profile { display: flex; align-items: center; gap: 9px; min-height: 34px; padding: 6px 0; color: var(--muted); }
.config-profile select { width: 130px; }
.config-subheading, .config-section-title { padding: 10px 0 6px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 12px; }
.config-fields { display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)); gap: 8px 12px; }
.compact-fields { grid-template-columns: 1fr; gap: 5px; }
.config-field { display: grid; grid-template-columns: minmax(0, 1fr) 92px; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.config-field input { width: 100%; min-height: 26px; }
.checkbox-field { display: flex; align-items: center; gap: 7px; min-height: 26px; color: var(--muted); font-size: 11px; }
.checkbox-field input, .checkbox-line input { accent-color: var(--blue); }
.config-footnote { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line-soft); }
.overview-positions, .overview-records { margin-top: 10px; }

.table-scroll { width: 100%; overflow-x: auto; }
.data-table { width: 100%; min-width: 980px; border-collapse: collapse; }
.data-table th, .data-table td { padding: 6px 8px; border-top: 1px solid var(--line-soft); text-align: left; white-space: nowrap; }
.data-table th { color: var(--muted); font-size: 11px; font-weight: 500; }
.data-table td { font-size: 12px; }
.data-table tbody tr:nth-child(even) { background: #f0f3f7; }
.data-table td strong { font-weight: 500; }
.empty-state { padding: 18px 8px; color: var(--muted); text-align: center; }
.large-empty { min-height: 150px; display: grid; place-items: center; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.neutral { color: var(--text) !important; }
.records-group { margin-top: 10px; }
.records-scroll { max-height: 320px; }

.manual-form { display: grid; gap: 10px; }
.manual-form > label, .manual-grid > label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.manual-form input { width: 100%; }
.live-layout { display: grid; grid-template-columns: minmax(360px, 560px) minmax(320px, 1fr); gap: 10px; margin-bottom: 10px; }
.live-config-group, .live-control-group { min-height: 360px; }
.live-form { display: grid; gap: 10px; margin-top: 12px; }
.live-form > label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.live-form input, .live-form select { width: 100%; }
.live-inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.live-inline-fields label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.live-actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.live-warning { margin: 12px 0; color: var(--red); font-size: 12px; }
.live-command-actions { margin-top: 18px; }
.live-metrics { display: grid; grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 8px 18px; margin-top: 24px; border-top: 1px solid var(--line-soft); }
.live-metrics > div { display: flex; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); color: var(--muted); font-size: 11px; }
.live-metrics strong { color: var(--text); font-weight: 500; text-align: right; }
.side-choice { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.checkbox-line { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 7px; }
.submit-order { justify-self: start; }
.account-mini, .account-list { margin-top: 18px; border-top: 1px solid var(--line-soft); }
.account-mini > div, .account-list > div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); color: var(--muted); font-size: 11px; }
.account-mini strong, .account-list strong { color: var(--text); font-weight: 500; text-align: right; }
.account-group { min-height: 260px; }
.manual-layout { display: grid; grid-template-columns: minmax(340px, 560px) minmax(280px, 420px); gap: 10px; margin-bottom: 10px; }
.manual-order-large { min-height: 250px; }
.manual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-message { min-height: 18px; margin: 0; color: var(--yellow); font-size: 11px; }

.config-workspace { padding: 12px 16px 16px; }
.config-details { margin-top: 10px; padding: 0 0 10px; }
.config-details summary { padding: 9px 0; color: var(--muted); cursor: pointer; }
.config-details[open] summary { border-bottom: 1px solid var(--line-soft); margin-bottom: 9px; }
.config-actions { display: flex; align-items: center; gap: 7px; margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 11px; }
.config-actions span { margin-right: auto; }
.raw-config-group { margin-top: 10px; }
.raw-config-group textarea { margin-top: 4px; }
.market-intro { margin-bottom: 10px; }
.market-stats { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 13px; padding-top: 10px; border-top: 1px solid var(--line-soft); color: var(--muted); }
.market-stats strong { margin-left: 5px; color: var(--text); font-weight: 500; }
.market-table { min-width: 620px; }
.hft-header { margin-bottom: 10px; }

@media (max-width: 1380px) {
  .overview-page { grid-template-columns: minmax(290px, 360px) minmax(500px, 1fr); }
  .manual-pane { grid-column: 1 / -1; min-height: 0; max-height: none; }
  .manual-pane .manual-form { grid-template-columns: repeat(4, minmax(140px, 1fr)); align-items: end; }
  .manual-pane .account-mini { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 12px; }
  .manual-pane .account-mini > div { flex: 1 1 130px; border-bottom: 0; }
}
@media (max-width: 980px) {
  .command-bar { align-items: flex-start; flex-direction: column; }
  .command-meta { width: 100%; }
  .tab-status { margin-left: auto; }
  .overview-page { display: block; }
  .overview-page.active { display: block; }
  .config-pane, .manual-pane { max-height: none; min-height: 0; margin-bottom: 10px; }
  .workbench-grid, .manual-layout, .live-layout { grid-template-columns: 1fr; }
  .manual-pane .manual-form { grid-template-columns: 1fr 1fr; }
  .manual-pane .submit-order { align-self: end; }
  .config-fields { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
}
@media (max-width: 620px) {
  body { font-size: 12px; }
  .command-bar, .tab-bar, .workspace { padding-left: 9px; padding-right: 9px; }
  .command-main { gap: 4px; }
  .toolbar-separator { display: none; }
  .command-meta { flex-wrap: wrap; white-space: normal; }
  .token-editor { position: fixed; top: 80px; left: 9px; right: 9px; }
  .token-editor input { width: 100%; }
  .tab-button { min-width: 94px; }
  .notice { padding-left: 10px; padding-right: 10px; }
  .workspace { padding-top: 9px; }
  .workbench-heading { align-items: flex-start; }
  .workbench-heading h1, .page-heading h1 { font-size: 19px; }
  .config-fields, .manual-grid, .live-inline-fields, .manual-pane .manual-form { grid-template-columns: 1fr; }
  .config-field { grid-template-columns: minmax(0, 1fr) 110px; }
  .manual-pane .submit-order { align-self: start; }
  .config-actions { flex-wrap: wrap; }
  .config-actions span { flex-basis: 100%; }
  .data-table { min-width: 900px; }
  .overview-positions, .overview-records { padding-left: 7px; padding-right: 7px; }
}
