/* Workspaces share the reporting and form typography of the trading console. */
:root {
  --ui-bg: #0a0d13;
  --ui-rail: #0d1119;
  --ui-surface: #111620;
  --ui-surface-2: #161c28;
  --ui-surface-3: #1c2432;
  --ui-line: #232b3a;
  --ui-line-strong: #364255;
  --ui-text: #e8ecf3;
  --ui-muted: #9aa4b5;
  --ui-faint: #8a94a6;
  --ui-brand: #2f6feb;
  --ui-brand-ink: #fff;
  --ui-brand-soft: #2f6feb21;
  --ui-up: #22c38e;
  --ui-down: #f2555a;
  --ui-warn: #f0b429;
  --ui-info: #7fb0ff;
  --ui-mono: "JetBrains Mono", SFMono-Regular, Consolas, ui-monospace, monospace;
  --ui-font: Inter, -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;

}
body { background: var(--ui-bg) !important; }
.workspace-content .grid > [data-workspace][hidden] { display: none !important; }
.workspace-content .grid > .card, .auth-card { box-shadow: none !important; }
body { font-size: 14px; line-height: 1.45; }
.workspace .grid > .card[data-workspace], #live-workspace[data-workspace] {
  background: var(--ui-surface) !important; border-color: var(--ui-line) !important;
}
.workspace-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.rail-nav a { min-height: 42px; }
:is(.rail-nav, .mobile-nav) a[aria-current] {
  background: var(--ui-surface-2) !important; color: var(--ui-text) !important;
  border-color: transparent !important; box-shadow: none !important;
}
.overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.overview-head { grid-column: 1/-1; display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 7px 0 10px; }
.overview-head h1 { margin: 0; font-size: clamp(25px, 3vw, 38px); line-height: 1.2; letter-spacing: -.04em; color: var(--ui-text); }
.overview-head p, .overview-head time, .overview-hint { font-size: 13px; line-height: 1.55; color: var(--ui-muted); }
.overview-head p { margin: 8px 0 0; overflow-wrap: anywhere; }
.overview-head time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.overview-panel {
  min-width: 0; align-self: start; overflow: hidden; border-radius: 14px;
  border: 1px solid var(--ui-line); background: var(--ui-surface); color: var(--ui-text);
}

.overview-panel > summary { display: flex; align-items: center; gap: 9px; padding: 16px 16px 10px; cursor: pointer; list-style: none; color: var(--ui-text); font-size: 15px; font-weight: 650; }
.overview-panel > summary::-webkit-details-marker { display: none; }
.overview-panel > summary::after { content: ''; margin-left: auto; width: 6px; height: 6px; border: solid var(--ui-muted); border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); }
.overview-panel[open] > summary::after { transform: rotate(45deg); }
.overview-panel > summary small { color: var(--ui-muted); font-size: 11px; letter-spacing: .06em; }
.overview-panel > summary:focus-visible { outline-offset: -4px; }
.earnings-body, .overview-body, .rate-list, .overview-jumps { padding: 0 16px 16px; }
.overview-value { display: block; font-size: 32px; letter-spacing: -.045em; line-height: 1.1; font-weight: 600; overflow-wrap: anywhere; }
.overview-value, .overview dd, .rate-row strong { font-variant-numeric: tabular-nums; }
.overview-hint { margin: 7px 0 16px; overflow-wrap: anywhere; }
.overview dl { margin: 0; }
.overview dt { color: var(--ui-muted); font-size: 13px; }
.overview dd { margin: 0; font-weight: 600; }
.earnings-total { margin-top: 6px; font: 600 16px var(--ui-mono); }
.earnings-total .overview-value { display: inline; font: 600 30px var(--ui-mono); letter-spacing: -.5px; }
.overview .outcomes { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin-top: 12px; }
.outcomes > div { display: grid; align-content: center; gap: 4px; min-height: 65px; padding: 10px; border-radius: 10px; background: var(--ui-surface-2); }
.outcomes dt { font-size: 12px; }
.outcomes dd { font: 600 17px var(--ui-mono); overflow-wrap: anywhere; }
.outcomes dd small { font: inherit; }
.earnings-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--ui-faint); }
.earnings-foot a { color: var(--ui-info); text-decoration: none; }
.desk-slots-count { font: 600 12px var(--ui-mono); color: var(--ui-text); }
.desk-slots { display: grid; grid-template-columns: repeat(5,1fr); gap: 4px; margin-top: 10px; }
.desk-slots i { height: 6px; border-radius: 3px; background: #2a3242; }
.desk-slots i.used { background: var(--ui-up); }
.positions-caption { margin: 0; padding: 16px 0; text-align: center; color: var(--ui-faint); font-size: 13px; }
.execution-state { display: flex; align-items: center; gap: 10px; font-size: 22px; line-height: 1.4; font-weight: 650; }
.execution-state i { width: 9px; height: 9px; border-radius: 50%; background: var(--ui-muted); }
.execution-state i.is-ready { background: var(--ui-up); }
.execution-state i.is-waiting { background: var(--ui-warn); }
.execution-rows { display: grid; gap: 8px; border-top: 1px solid var(--ui-line); padding-top: 12px; }
.execution-rows div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.execution-rows dd { font-size: 14px; }
.rate-row { display: grid; grid-template-columns: 65px minmax(20px,1fr) 56px; gap: 14px; align-items: center; min-height: 42px; font-size: 13px; color: var(--ui-muted); }
.rate-row strong { color: var(--ui-text); text-align: right; }
.rate-track { height: 6px; background: var(--ui-line-strong); border-radius: 3px; overflow: hidden; }
.rate-track i { display: block; height: 100%; background: var(--ui-up); }
.overview-jumps a { display: flex; align-items: center; justify-content: space-between; min-height: 42px; color: var(--ui-text); text-decoration: none; font-size: 14px; }
.overview-jumps a + a { border-top: 1px solid var(--ui-line); }
.overview-jumps a span { color: var(--ui-info); }
.overview-jumps a:hover { color: var(--ui-info); }
/* Desktop uses a full-height rail, with the current workspace title in the header. */
.shell { --rail-width: 184px; }
.desk-number { font: 600 28px var(--ui-mono); letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.desk-number small { font-size: 16px; color: var(--ui-muted); }
.desk-link, .rail-account a { color: var(--ui-info); font-size: 13px; text-decoration: none; }
.desk-link:hover, .rail-account a:hover { text-decoration: underline; }
.workspace-page-title { font-size: 22px; font-weight: 600; color: var(--ui-text); }
.overview-head { margin: 0; gap: 10px; }
.overview-head h1 { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
.overview-head p { margin: 0; padding: 4px 10px; border-radius: 13px; background: var(--ui-surface-2); color: #c9d1de; font-size: 12px; }
.rail-account { margin-top: auto; padding: 14px; border: 1px solid var(--ui-line); border-radius: 14px; background: var(--ui-surface); }
.rail-account h2 { margin: 0; font-size: 13px; font-weight: 600; }
.rail-account p { margin: 6px 0 12px; font-size: 13px; color: var(--ui-muted); }
.rail-account a { display: block; padding: 7px; text-align: center; color: var(--ui-text); background: var(--ui-surface-2); border: 1px solid var(--ui-line); border-radius: 10px; }
@media (min-width: 821px) and (pointer: fine), (min-width: 1024px) {
  html body .shell { margin: 0; width: 100%; max-width: none; padding: 0 24px 50px calc(var(--rail-width) + 24px); }
  .shell .workspace { display: block; margin: 0; }
  .shell .topbar { min-height: 74px; padding: 20px 0 10px; margin: 0; border: 0 !important; }
  .market-sidebar.terminal-rail { position: fixed; inset: 0 auto 0 0; width: var(--rail-width); display: flex; flex-direction: column;
    padding: 86px 14px 20px; z-index: 20; overflow-y: auto; background: var(--ui-rail) !important; border-right: 1px solid var(--ui-line) !important; }
  .shell .brand-link { position: fixed; top: 22px; left: 16px; z-index: 21; }
  .rail-nav a, .rail-nav a:first-of-type { font-size: 14px; font-weight: 400; border-radius: 8px !important; }
  .shell .mobile-nav { display: none; }
}
@media (min-width: 821px) and (max-width: 1140px) {
  .shell { --rail-width: 160px; }
  .overview { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 820px), (max-width: 1023px) and (pointer: coarse) {
  html body .shell { padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)) !important; }
  .shell .topbar { min-height: 64px; padding-block: 12px; border: 0 !important; margin: 0; }
  .shell .brand-link { display: none; }
  .overview { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .mobile-nav { grid-template-columns: repeat(6, minmax(0,1fr)) !important; min-height: 59px; background: #0f131b !important; backdrop-filter: none; }
  html body .mobile-nav a[aria-current] { color: var(--ui-text) !important; background: transparent !important; }
}
@media (max-width: 640px) {
  .overview { grid-template-columns: minmax(0,1fr); }
  .overview-head { flex-wrap: wrap; }
  .overview-head time { font-size: 12px; }
}
@media (min-width: 821px) and (max-width: 1050px) {
  #backtest-settings { grid-template-columns: minmax(0, 1fr); }
  #backtest-settings .workbench-launch { padding-top: 0; justify-items: start; }
}
@media (max-width: 360px) {
  html body .shell { padding-inline: max(6px, env(safe-area-inset-left)) max(6px, env(safe-area-inset-right)) !important; }
}

/* Keep state legible by shape as well as color. Native summaries retain keyboard operation. */
.module-heading { display: flex; align-items: center; }
.overview-jumps .jump-arrow, .workspace :is(.report-fold, .collapsible-module) > summary::after {
  content: ''; display: inline-block; width: 7px; height: 7px; flex: none;
  border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg);
}
.workspace :is(.report-fold, .collapsible-module)[open] > summary::after { content: ''; transform: rotate(45deg); }
.live-readiness { align-items: center; }
.live-readiness .readiness-mark {
  display: inline-block; width: 9px; height: 9px; flex: none; box-shadow: none;
}
.live-readiness .ready .readiness-mark {
  background: transparent; width: 6px; height: 10px; border: solid var(--ui-up);
  border-width: 0 2px 2px 0; border-radius: 0; transform: rotate(45deg);
}
.live-readiness .waiting .readiness-mark { background: transparent; border: 1.5px solid var(--ui-warn); border-radius: 50%; }
.live-readiness .status-sr {
  position: absolute; width: 1px; height: 1px; padding: 0 !important; border: 0 !important;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* Shared controls and data surfaces use the same type scale in every workspace. */
.shell .card, .auth-card { border-radius: 14px !important; box-shadow: none !important; }
.shell .workbench-head, .shell .module-details > summary { background: transparent !important; }
.shell .workbench-head h1, .shell .workbench-head h2, .shell .module-name,
.shell .section-title, .shell .cloud-live-subhead, .shell .health-title { color: var(--ui-text); font-size: 15px; font-weight: 600; }
.overview-panel > summary { font: 400 12px/1.45 var(--ui-font); color: var(--ui-muted); padding: 16px 16px 0; }
.overview-panel:not([open]) > summary { padding-bottom: 16px; }
.shell button:not(.secondary):not(.danger):not(.stop-button):not(.quiet-danger):not([role="tab"]) { color: white; }
.shell input:not([type="checkbox"]):not([type="radio"]), .shell textarea, .shell select, .auth input {
  background-color: var(--ui-rail) !important; border-color: var(--ui-line-strong) !important; border-radius: 10px !important;
}
.shell .pill, .shell .module-badge { font-weight: 500; }
.shell table th { background: var(--ui-surface) !important; font-weight: 500; }
.shell table td, .shell table th { font-variant-numeric: tabular-nums; }
.shell .workbench-presets button, .shell .ui-quick-times button {
  background: var(--ui-surface-2) !important; color: #c9d1de !important; border-color: var(--ui-line) !important; border-radius: 17px !important;
}
.shell .backtest-detail-tabs { padding: 4px !important; background: var(--ui-rail) !important; border-radius: 10px; }
.shell .backtest-detail-tabs button { border: 0 !important; background: transparent !important; color: var(--ui-muted) !important; }
.shell .backtest-detail-tabs button.active, .shell .backtest-detail-tabs button[aria-selected="true"] { background: var(--ui-line) !important; color: var(--ui-text) !important; }
.shell .report-fold, .shell .execution-focus, .shell .health-item, .shell .cloud-extension, .shell .real-config { border-color: var(--ui-line) !important; }
.shell .real-order-result.negative, .shell .kpi-value.negative, .shell .health-value.negative { color: var(--ui-down); }

/* Execution and research keep separate content cards under the page heading. */
html body .workspace-content .grid > :is(#live-workspace, #backtest-workspace) {
  background: transparent !important; border: 0 !important; padding: 0 !important;
}
:is(#live-workspace, #backtest-workspace) > .workbench-head { padding: 0 0 12px !important; border: 0; min-height: 0; }
:is(#live-workspace, #backtest-workspace) > .workbench-head h1 { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
:is(#live-workspace, #backtest-workspace) > .workbench-head > div { display: contents; }
#backtest-workspace > .workbench-head:not(:has(.pill)) { display: none; }
:is(#live-workspace, #backtest-workspace) > .workbench-body { padding: 0; }
#live-trading, #backtest-settings, #backtest-results, #strategy-library, #strategy-editor {
  background: var(--ui-surface) !important; border: 1px solid var(--ui-line) !important;
  border-radius: 14px !important; box-shadow: none !important; padding: 16px !important;
}
#backtest-results, #strategy-library, #strategy-editor { margin-block-start: 12px; }
#live-trading > .module-body { padding: 0 !important; }
.shell .live-metrics { background: var(--ui-rail); border-color: var(--ui-line); }
.shell .live-metrics .live-next-time, .shell .cloud-candidate-score strong { color: var(--ui-text); }
.shell .brand { font-size: 16px !important; letter-spacing: .015em !important; font-weight: 600 !important; }
@media (min-width: 821px) and (max-width: 1140px) {
  .shell .brand { font-size: 14px !important; gap: 6px !important; }
  .shell .brand-link { left: 14px; }
}

.overview-panel > summary::after { border-color: var(--ui-faint); }
.overview-panel .overview-body > .desk-number, .overview-panel .execution-state { display: block; margin-top: 6px; }
.overview-panel .execution-state { display: flex; }
.overview-panel .rate-list { padding-top: 12px; }
.rate-row { grid-template-columns: minmax(0,1fr) auto; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--ui-text); }
.rate-row strong { grid-column: 2; grid-row: 1; font: 600 15px/1.45 var(--ui-mono); }
.rate-row .rate-track { grid-column: 1/-1; grid-row: 2; height: 8px; background: var(--ui-surface-2); }
.execution-rows dd, .overview time, .kpi-value, .health-value, .workbench-kpi strong { font-family: var(--ui-mono); }
.overview-panel .desk-link { display: block; width: fit-content; }
.shell .pill.positive { color: var(--ui-up) !important; background: var(--ui-surface-2) !important; border-color: var(--ui-line) !important; }
.rail-account h2 { color: var(--ui-muted); font: 400 12px/1.45 var(--ui-font); }
.desk-orders { min-width: 0; }
.orders-toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin: 0 0 12px; }
.orders-toolbar label { min-width: 126px; }
.orders-toolbar > span { color: var(--ui-muted); font-size: 13px; padding: 8px 0; }
.desk-orders .report-fold { min-width: 0; margin: 0 0 12px; border: 1px solid var(--ui-line); background: var(--ui-surface); border-radius: 14px; }
.desk-orders .real-orders-table { overflow: auto; max-height: min(65vh,620px); }
.desk-orders .report-title-block strong { color: var(--ui-text); font: 600 15px var(--ui-font); }
@media (max-width: 640px) {
  .orders-toolbar label { min-width: 110px; }
  .outcomes > div { padding: 8px; }
}
.desk-orders .report-fold > summary { background: transparent; padding: 16px; min-height: 60px; }
.desk-orders .report-fold > summary:hover { background: var(--ui-surface-2); }
.desk-orders .report-fold-body { border-color: var(--ui-line); }
.desk-orders .report-title-block small, .desk-orders .real-order-note { color: var(--ui-faint); }
.desk-orders .failure-reason, .desk-orders .real-order-result.negative { color: var(--ui-down); }
.desk-orders .real-order-result.positive { color: var(--ui-up); }
@media (max-width: 820px) {
  .desk-orders .real-orders-table tbody > tr { background: var(--ui-surface-2); border: 1px solid var(--ui-line); border-radius: 10px; box-shadow: none; }
  .desk-orders .real-orders-table td::before { color: var(--ui-muted); font-weight: 400; }
}

.mobile-order-days { display: none; }
@media (max-width: 820px), (max-width: 1023px) and (pointer: coarse) {
  #orders-workspace :is(.real-orders-table, .real-orders-footer) { display: none !important; }
  .mobile-order-days { display: grid; gap: 10px; min-width: 0; }
  .mobile-order-days .order-day { margin: 0; padding: 0; border: 1px solid var(--ui-line); border-radius: 10px; background: var(--ui-surface); overflow: hidden; }
  .order-day > summary { display: flex; align-items: center; gap: 8px; padding: 10px; cursor: pointer; background: var(--ui-surface-2); color: var(--ui-text); font: 600 13px var(--ui-mono); list-style: none; }
  .order-day > summary::-webkit-details-marker { display: none; }
  #orders-workspace .real-orders-head { flex-direction: row; justify-content: flex-end; margin-bottom: 8px; }
  #orders-workspace .real-orders-head > span, #orders-workspace .cloud-inline-status:empty { display: none; }
  .order-day > summary::after { margin-left: auto; content: ''; width: 6px; height: 6px; border: solid var(--ui-muted); border-width: 0 1px 1px 0; transform: rotate(-45deg); }
  .order-day[open] > summary::after { transform: rotate(45deg); }
  .day-grid { display: grid; grid-template-columns: 62px 27px minmax(0,1fr) 59px; gap: 5px; align-items: center; padding: 8px; font: 12px/1.45 var(--ui-mono); }
  .day-grid > :last-child:not(.day-reason) { text-align: right; }
  .day-head { color: var(--ui-muted); font: 11px/1.4 var(--ui-font); }
  .day-row { border-top: 1px solid var(--ui-line); color: var(--ui-text); }
  .day-key { display: block; color: var(--ui-muted); font: 10px/1.4 var(--ui-font); }
  .day-prices { min-width: 0; overflow-wrap: anywhere; }
  .day-prices span { display: inline-block; max-width: 100%; }
  .day-prices i { color: var(--ui-muted); font-style: normal; }
  .day-pnl { font-variant-numeric: tabular-nums; }
  .day-long, .day-win { color: var(--ui-up); }
  .day-short, .day-loss { color: var(--ui-down); }
  .day-reason { grid-column: 3 / -1; overflow-wrap: anywhere; }
  .day-empty { text-align: center; color: var(--ui-muted); }
  .day-more { justify-self: center; }
}

/* The workspace grid supplies one common inset on both layouts. */
.grid[data-mode="live"] [data-environment="paper"],
.grid[data-mode="paper"] [data-environment="live"] { display: none !important; }
.workspace-content .grid > [data-workspace] { min-width: 0; width: 100%; box-sizing: border-box; margin-inline: 0 !important; }
.overview { align-items: stretch; }
.overview-panel { align-self: stretch; }
.card-heading, .day-heading { margin: 0; padding: 14px 16px; color: var(--ui-text); font: 600 15px/1.4 var(--ui-font); }
.overview-panel > .card-heading { padding-bottom: 8px; color: var(--ui-muted); font-size: 13px; font-weight: 500; }
.card-heading.module-summary, .card-heading.health-head { display:flex; flex-wrap:wrap; gap:10px; align-items:center; justify-content:space-between; }
.card-heading::after { display:none !important; }
.overview-panel > .card-heading b { float:right; }
.environment-switch { display: inline-flex; gap: 2px; border: 1px solid var(--ui-line); border-radius: 8px; background: var(--ui-surface); padding: 3px; }
.shell .environment-switch button { border: 0 !important; border-radius: 5px !important; background: transparent !important; color: var(--ui-muted); padding: 5px 12px; min-height: 29px; box-shadow: none !important; font: 500 13px/1.4 var(--ui-font); }
.shell .environment-switch button[aria-pressed="true"] { color: white !important; background: var(--ui-brand) !important; }
.account-strip { display:flex; margin: 0 0 12px; }
.login-chip { display:inline-flex; align-items:center; gap:5px; padding:4px 9px; border:1px solid var(--ui-line); border-radius:99px; color:var(--ui-muted); background:var(--ui-surface); text-decoration:none; font: 12px/1.4 var(--ui-font); }
.login-chip i { width:7px; height:7px; border-radius:50%; background:currentColor; }
.login-chip.connected { color:var(--ui-up); }
#trade-workspace > section, #account-workspace > section { box-sizing:border-box; width:100%; margin:0 !important; }
#trade-workspace #live-workspace { padding:0 !important; border:0 !important; background:transparent !important; }
#trade-workspace #live-workspace > .workbench-head { display:none; }
#account-workspace #connection-health, #trade-workspace #live-simulation { background:var(--ui-surface); border:1px solid var(--ui-line); border-radius:14px; }
#account-workspace .cloud-account-panel { padding:16px; }
.quote-main { display:flex; justify-content:space-between; gap:8px; align-items:center; padding:0 16px; }
.quote-price { font:650 clamp(23px,2.1vw,34px)/1.25 var(--ui-mono); white-space:nowrap; color:var(--ui-text); }
.quote-line { flex:0 1 30%; min-width:40px; max-width:134px; height:56px; }
.quote-change,.quote-source,.quote-card footer small { font-size:12px; color:var(--ui-muted); }
.quote-card :is(.gain,.loss),.quote-change { font-variant-numeric:tabular-nums; }
.quote-card .gain { color:var(--ui-up); } .quote-card .loss { color:var(--ui-down); }
.quote-source { display:block; margin:4px 16px; }
.quote-card footer { display:flex; align-items:baseline; flex-wrap:wrap; gap:4px 10px; margin:14px 16px; padding-top:10px; border-top:1px solid var(--ui-line); }
.quote-card footer span { width:100%; color:var(--ui-muted); font-size:12px; }
.quote-card footer strong { font:600 17px var(--ui-mono); }
.daily-orders { display:grid; min-width:0; gap:12px; }
.daily-orders .order-day { border:1px solid var(--ui-line); border-radius:10px; overflow:hidden; min-width:0; }
.day-heading { padding:9px 12px; font:600 13px/1.5 var(--ui-mono); background:var(--ui-surface-2); }
#orders-workspace .order-day .real-orders-table { max-height:none; margin:0; }
.day-grid { display:grid; grid-template-columns:62px 40px minmax(0,1fr) 78px; align-items:center; gap:6px; padding:8px; font:12px/1.5 var(--ui-mono); }
.day-pnl,.day-grid .day-pnl,.day-grid > :last-child:not(.day-reason) { text-align:right; }
.day-long,.day-win { color:var(--ui-up); } .day-short,.day-loss { color:var(--ui-down); }
.day-row { border-top:1px solid var(--ui-line); }
.day-head { color:var(--ui-muted); }
.day-more { justify-self:center; }
@media (max-width:820px), (max-width:1023px) and (pointer:coarse) {
  .rail-account,.desk-orders .real-orders-head { display:none !important; }
  .shell .topbar { display:flex; align-items:center; justify-content:space-between; }
  .shell .topbar-status { display:flex; gap:6px; align-items:center; }
  .shell .environment-switch button { padding-inline:9px; }
  .day-grid { grid-template-columns:42px 27px minmax(0,1fr) 59px; }
}
@media (max-width:820px), (max-width:1023px) and (pointer:coarse) {
  .shell button.manual-refresh { display:none !important; }
}
/* Size the desktop order tables to their day card, including side-by-side windows. */
#orders-workspace .order-records { container-type:inline-size; overflow:visible; }
#orders-workspace .order-records table { width:100%; min-width:0; table-layout:fixed; }
#orders-workspace .order-records :is(th,td,.pill,.real-order-note) {
  min-width:0; max-width:100%; white-space:normal; overflow-wrap:anywhere;
}
#orders-workspace .order-records :is(th,td) { padding:10px 6px; }
#live-orders .order-records th:first-child { width:12%; }
#live-orders .order-records th:nth-child(3) { width:8%; }
#live-failed-orders .order-records th:nth-child(5) { width:40%; }
#orders-workspace .cloud-inline-status:empty { display:none; }

@container (max-width: 860px) {
  #live-failed-orders .order-records table, #live-failed-orders .order-records tbody { display:block; }
  #live-failed-orders .order-records thead { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
  #live-failed-orders .order-records tbody > tr {
    display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px 16px; padding:12px 16px;
  }
  #live-failed-orders .order-records tbody > tr + tr { border-top:1px solid var(--ui-line); }
  #live-failed-orders .order-records tbody td {
    display:block; width:auto; padding:0; text-align:left; border:0; grid-column:auto;
  }
  #live-failed-orders .order-records td::before {
    content:attr(data-label); display:block; margin-bottom:3px; font:400 11px/1.4 var(--ui-font); color:var(--ui-muted);
  }
  #live-failed-orders .order-records .failure-reason { grid-column:span 2; }
}

#live-orders .order-records :is(th,td,.pill) {
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; overflow-wrap:normal;
}
#live-orders .order-records .pill { display:inline; padding:0 !important; background:none !important; border:0 !important; }
@container (max-width: 860px) {
  #live-orders .order-records :is(th,td):is(:nth-child(6),:nth-child(8)) { display:none; }
  #live-orders .order-records th:first-child { width:15%; }
  #live-orders .order-records th:nth-child(3) { width:10%; }
}
@container (max-width: 640px) {
  #live-orders .order-records :is(td,th):nth-child(2) { display:none; }
  #live-orders .order-records :is(th,td) { padding-inline:4px !important; }
}

/* Live overview instruments */
:is(#overview-signal,#overview-execution,#overview-rates) {
  display:flex; flex-direction:column; padding:18px 20px 14px; box-sizing:border-box;
}
:is(#overview-signal,#overview-execution,#overview-rates) > .card-heading {
  padding:0; font-size:14px; line-height:20px;
}
.instrument-reading { display:flex; align-items:center; justify-content:space-between; gap:8px; flex:1; min-height:83px; }
.instrument-score { font:600 clamp(30px,2.75vw,44px)/1 var(--ui-mono); letter-spacing:-.055em; white-space:nowrap; }
.instrument-score span { margin-left:2px; color:var(--ui-muted); font-size:.52em; }
.candidate-outcome { max-width:56%; padding:5px 9px; border-radius:6px; text-align:right; font:550 14px/1.45 var(--ui-font); overflow-wrap:anywhere; color:var(--ui-muted); background:var(--ui-surface-2); }
.candidate-outcome.outcome-blocked { color:var(--ui-warn); }
.candidate-outcome.outcome-ready, .candidate-outcome.outcome-done { color:var(--ui-up); }
.instrument-foot { display:flex; align-items:center; justify-content:space-between; gap:8px; min-height:24px; padding-top:10px; border-top:1px solid var(--ui-line); font:500 13px/1.4 var(--ui-font); }
.signal-time { color:var(--ui-muted); }
.signal-time time { color:var(--ui-text); font:500 14px var(--ui-mono); }
.strategy-foot > span { overflow-wrap:anywhere; color:var(--ui-muted); }
.strategy-foot .desk-link { flex:none; color:var(--ui-info); }
#overview-execution .execution-state { margin:0; gap:12px; }
.execution-state strong { font-size:clamp(20px,1.9vw,30px); line-height:1.22; }
.power-mark { display:grid; place-items:center; flex:none; width:40px; height:40px; border-radius:12px; background:var(--ui-surface-2); color:var(--ui-muted); }
.running .power-mark { color:var(--ui-up); background:color-mix(in srgb,var(--ui-up) 12%,var(--ui-surface)); }
.waiting .power-mark { color:var(--ui-warn); }
#overview-execution .power-mark i { position:relative; box-sizing:border-box; width:19px; height:19px; border:2px solid; border-top-color:transparent; border-radius:50%; background:transparent; }
.power-mark i::after { content:''; position:absolute; top:-3px; left:calc(50% - 1px); width:2px; height:10px; border-radius:2px; background:currentColor; }
.win-rate-list { display:grid; gap:9px; padding-top:10px; }
.win-rate-period { --reading-color:var(--ui-muted); display:grid; grid-template-columns:1fr auto; align-items:baseline; gap:4px 10px; font-size:13px; }
.win-rate-period.above { --reading-color:var(--ui-up); }
.win-rate-period.below { --reading-color:var(--ui-down); }
.win-rate-period strong { color:var(--reading-color); font:600 16px/1.2 var(--ui-mono); }
.win-rate-track { position:relative; grid-column:1/-1; height:6px; border-radius:6px; background:var(--ui-surface-2); }
.win-rate-track i { display:block; height:100%; border-radius:inherit; background:var(--reading-color); }
.win-rate-track b { position:absolute; top:-2px; bottom:-2px; width:2px; transform:translateX(-50%); background:var(--ui-down); box-shadow:0 0 0 1px var(--ui-surface); }
.win-rate-key { display:flex; align-items:center; gap:6px; margin-top:12px; color:var(--ui-muted); font-size:13px; font-variant-numeric:tabular-nums; }
.win-rate-key i { width:2px; height:10px; background:var(--ui-down); }
@media (prefers-reduced-motion:no-preference) {
  .win-rate-track i { transform-origin:left; animation:overview-bars-in .4s ease-out; transition:width .4s ease-out; }
  .running .power-mark i { animation:overview-power 3s ease-in-out infinite; }
}
@keyframes overview-bars-in { from {transform:scaleX(0);} to {transform:scaleX(1);} }
@keyframes overview-power { 50% {opacity:.62;} }

#live-simulation > .module-body { padding:16px; }
#live-simulation .paper-metrics { margin:12px 0 18px; background:var(--ui-rail); border-color:var(--ui-line); }
#orders-workspace .paper-orders :is(th,td) { white-space:nowrap; }

#overview-signal .candidate-heading { display:grid; gap:4px; }
.candidate-side { font:600 13px/1.3 var(--ui-font); }
.candidate-side.day-long { color:var(--ui-up); }
.candidate-side.day-short { color:var(--ui-down); }

/* Trading views share navigation and retain their controls while switching modes. */
#trade-workspace .trade-views {
  display:flex; align-items:stretch; gap:8px; margin:0 0 16px;
  border-bottom:1px solid var(--ui-line);
}
#trade-workspace .trade-views a {
  padding:11px 18px; margin-bottom:-1px; border-bottom:2px solid transparent;
  color:var(--ui-muted); text-decoration:none; font:600 14px/1.5 var(--ui-font);
}
#trade-workspace .trade-views a:hover { color:var(--ui-text); }
#trade-workspace .trade-views a[aria-current] { color:var(--ui-text); border-bottom-color:var(--ui-brand); }
#trade-workspace .trade-views a:focus-visible { outline:2px solid var(--ui-brand); outline-offset:-3px; }
#trade-workspace:not([data-trade-page="execute"]) [data-trade-view="execute"],
#trade-workspace:not([data-trade-page="settings"]) [data-trade-view="settings"],
#trade-workspace:not([data-trade-page="performance"]) [data-trade-view="performance"],
#trade-workspace[data-trade-page="performance"] #live-trading { display:none !important; }
#trade-workspace .live-status .cloud-status-copy p,
#trade-workspace .cloud-inline-status { white-space:normal; overflow-wrap:anywhere; }
#trade-workspace .cloud-inline-status:empty { display:none; }
#trade-workspace .trade-actions { gap:8px; margin:12px 0; }
#trade-workspace .live-actions { margin:0 0 14px; }
#trade-workspace .live-metrics strong { white-space:normal; overflow-wrap:anywhere; }
#trade-workspace .live-next-time { white-space:nowrap; }
@media(max-width:640px) {
  #trade-workspace .trade-views { gap:0; margin-bottom:12px; }
  #trade-workspace .trade-views a { flex:1; text-align:center; }
  #trade-workspace .trade-actions button { min-height:42px; }
}
#trade-workspace .live-actions > .row { display:flex !important; flex-wrap:wrap; }
#trade-workspace .live-actions > .row > button {
  flex:0 1 auto; min-height:42px; padding-inline:18px; font-size:14px;
}
@media(max-width:640px) {
  #trade-workspace .live-actions > .row > button { flex:1 1 auto; }
  #trade-workspace .live-metrics { grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px !important; }
  #trade-workspace .live-metrics > div { grid-column:auto; min-height:0; padding:0; border:0; }
  #trade-workspace .live-metrics > div:first-child { grid-column:1 / -1; }
  #trade-workspace .live-metrics > div > span { margin-bottom:4px; }
  #trade-workspace .live-metrics > div:first-child strong { font-size:16px; }
}
