:root {
  color-scheme: dark;
  --bg: #070b0f;
  --surface: #0d141b;
  --surface-2: #111b24;
  --line: #22313d;
  --line-soft: #17232c;
  --text: #e8f0f5;
  --muted: #7d909e;
  --cyan: #27d6e6;
  --green: #19e68c;
  --red: #ff4d6d;
  --amber: #f4b942;
  --gold: #d6a72f;
  --blue: #5c8dff;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(39, 214, 230, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(39, 214, 230, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
}

.terminal-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 11, 15, 0.96);
  backdrop-filter: blur(14px);
}

.brand,
.header-status,
.connection,
.panel-header,
.section-heading,
.signal-panel > header,
.confidence > div:first-child,
.chart-legend,
.terminal-footer {
  display: flex;
  align-items: center;
}

.brand {
  gap: 13px;
}

.brand-mark {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  transform: rotate(45deg);
  border: 1px solid #f1c75b;
  background: var(--gold);
  box-shadow: 0 0 18px rgba(214, 167, 47, 0.32);
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 15px;
  line-height: 1.2;
}

.brand div > span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.header-status {
  gap: 18px;
  color: var(--muted);
  font-size: 12px;
}

.terminal-nav {
  display: flex;
  align-self: stretch;
  gap: 28px;
}

.terminal-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.terminal-nav a:hover {
  color: var(--text);
}

.terminal-nav a.active {
  color: var(--cyan);
}

.terminal-nav a.active::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--cyan);
  box-shadow: 0 0 10px rgba(39, 214, 230, 0.5);
  content: "";
}

.mode-badge {
  padding: 6px 9px;
  border: 1px solid rgba(244, 185, 66, 0.35);
  border-radius: 4px;
  color: var(--amber);
  background: rgba(244, 185, 66, 0.08);
  cursor: pointer;
}

.mode-badge.unlocked {
  border-color: rgba(39, 214, 230, 0.42);
  color: var(--cyan);
  background: rgba(39, 214, 230, 0.08);
}

.mode-badge.live {
  border-color: rgba(255, 77, 109, 0.5);
  color: var(--red);
  background: rgba(255, 77, 109, 0.08);
}

.connection {
  gap: 7px;
}

.connection i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}

.connection.online i {
  background: var(--green);
  box-shadow: 0 0 10px rgba(25, 230, 140, 0.7);
}

.latency-badge {
  min-width: 88px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  text-align: right;
}

.latency-badge.fast {
  color: var(--green);
}

.latency-badge.slow {
  color: var(--amber);
}

.latency-badge.stale {
  color: var(--red);
}

.connection.error i {
  background: var(--red);
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  font-size: 20px;
  line-height: 32px;
}

.icon-button:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.icon-button.loading {
  animation: spin 0.8s linear infinite;
}

main {
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 24px 28px 30px;
}

.market-strip {
  display: grid;
  grid-template-columns: 200px minmax(220px, 1fr) minmax(480px, 1.7fr) 180px;
  align-items: center;
  min-height: 104px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.market-identity span,
.market-time span,
.panel-header p,
.section-heading p,
.signal-panel > header > span {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.market-identity h1,
.panel-header h2,
.section-heading h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
}

.quote-primary {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.quote-primary strong {
  color: var(--cyan);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: clamp(30px, 3vw, 46px);
  line-height: 1;
}

.quote-primary span {
  font-weight: 700;
}

.positive {
  color: var(--green) !important;
}

.negative {
  color: var(--red) !important;
}

.quote-details {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin: 0;
}

.quote-details div {
  min-width: 0;
  padding: 3px 18px;
  border-left: 1px solid var(--line-soft);
}

.quote-details dt,
.trade-levels dt {
  color: var(--muted);
  font-size: 11px;
}

.quote-details dd {
  margin: 7px 0 0;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 15px;
  font-weight: 700;
}

.market-time {
  text-align: right;
}

.market-time strong {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.board-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  margin-top: 18px;
}

.chart-panel,
.signal-panel,
.trade-ticket,
.execution-panel,
.analysis-band,
.factor-panel,
.history-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(13, 20, 27, 0.92);
}

.chart-panel {
  min-width: 0;
  overflow: hidden;
}

.right-rail {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
}

.rail-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.rail-tabs button,
.execution-tabs button,
.order-type-control button {
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.rail-tabs button.active,
.execution-tabs button.active,
.order-type-control button.active {
  color: var(--cyan);
  background: rgba(39, 214, 230, 0.09);
  box-shadow: inset 0 -2px 0 var(--cyan);
}

.rail-view[hidden],
.execution-view[hidden] {
  display: none;
}

.panel-header,
.section-heading {
  justify-content: space-between;
  min-height: 64px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.chart-header-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.timeframe-control {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
}

.timeframe-control button {
  min-width: 54px;
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 3px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
}

.timeframe-control button:hover {
  color: var(--text);
}

.timeframe-control button.active {
  color: #071013;
  background: var(--cyan);
  font-weight: 750;
}

.chart-toolbar {
  display: flex;
  gap: 2px;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
}

.indicator-toggle,
.chart-tool-button {
  height: 30px;
  border: 0;
  border-radius: 3px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.indicator-toggle {
  min-width: 38px;
  padding: 0 7px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
}

.indicator-toggle:hover,
.chart-tool-button:hover {
  color: var(--text);
  background: var(--surface-2);
}

.indicator-toggle.active {
  color: var(--cyan);
  background: rgba(39, 214, 230, 0.1);
  box-shadow: inset 0 0 0 1px rgba(39, 214, 230, 0.25);
}

.chart-tool-button {
  width: 30px;
  padding: 0;
  font-size: 17px;
  line-height: 1;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  margin: 0 3px;
  background: var(--line);
}

.chart-wrap {
  position: relative;
  width: 100%;
  min-height: 510px;
  aspect-ratio: 16 / 8;
  background: #091017;
}

#klineChart {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
}

.chart-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(9, 16, 23, 0.82);
  font-size: 13px;
}

.chart-state[hidden] {
  display: none;
}

.chart-ohlc {
  position: absolute;
  z-index: 3;
  top: 10px;
  left: 12px;
  pointer-events: none;
  color: #9eb0ba;
  text-shadow: 0 1px 2px #091017;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  line-height: 1;
}

.viewport-status {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 76px;
  pointer-events: none;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}

.chart-legend {
  min-height: 38px;
  gap: 18px;
  padding: 0 16px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 11px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend .line {
  width: 18px;
  height: 2px;
}

.chart-legend .bar {
  width: 18px;
  height: 8px;
  border-right: 3px solid rgba(25, 230, 140, 0.65);
  border-left: 3px solid rgba(255, 77, 109, 0.65);
  background: rgba(125, 144, 158, 0.25);
}

.ema20 {
  background: var(--cyan);
}

.ema50 {
  background: var(--amber);
}

.ema200 {
  background: var(--blue);
}

.chart-legend .rsi {
  background: #b68cff;
}

.chart-legend .kdj-k {
  background: #27d6e6;
}

.chart-legend .kdj-d {
  background: #f4b942;
}

.chart-legend .kdj-j {
  background: #ff5c93;
}

.chart-legend .bollinger {
  background: #7d8df7;
}

.chart-legend .macd {
  background: #31c48d;
}

.chart-legend span.inactive {
  opacity: 0.35;
}

.chart-panel:fullscreen {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
  background: var(--surface);
}

.chart-panel:fullscreen .chart-wrap {
  min-height: 0;
  flex: 1;
  aspect-ratio: auto;
}

.chart-legend .marker {
  width: 0;
  height: 0;
  border-right: 5px solid transparent;
  border-left: 5px solid transparent;
}

.chart-legend .marker.buy {
  border-bottom: 8px solid var(--green);
}

.chart-legend .marker.sell {
  border-top: 8px solid var(--red);
}

.signal-panel {
  position: relative;
  overflow: hidden;
  padding-bottom: 16px;
}

.signal-panel::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px;
  background: var(--amber);
  content: "";
}

.signal-panel.buy::before {
  background: var(--green);
}

.signal-panel.sell::before {
  background: var(--red);
}

.signal-panel > header {
  justify-content: space-between;
  min-height: 64px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.signal-expiry {
  color: var(--muted);
  font-size: 10px;
}

.signal-expiry strong {
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
}

.signal-call {
  padding: 24px 18px 17px;
}

.signal-call span {
  display: block;
  color: var(--amber);
  font-size: 54px;
  font-weight: 850;
  line-height: 1;
}

.signal-panel.buy .signal-call span {
  color: var(--green);
}

.signal-panel.sell .signal-call span {
  color: var(--red);
}

.signal-call small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

.confidence {
  padding: 0 18px 18px;
}

.confidence > div:first-child {
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
}

.confidence strong {
  color: var(--text);
  font-size: 14px;
}

.confidence-track {
  height: 5px;
  overflow: hidden;
  background: #1a252e;
}

.confidence-track i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--amber);
  transition: width 300ms ease;
}

.signal-panel.buy .confidence-track i {
  background: var(--green);
}

.signal-panel.sell .confidence-track i {
  background: var(--red);
}

.trade-levels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 0 18px;
  border: 1px solid var(--line-soft);
  background: var(--line-soft);
}

.trade-levels div {
  min-width: 0;
  padding: 12px;
  background: #0b1218;
}

.trade-levels .wide {
  grid-column: 1 / -1;
}

.trade-levels dd {
  overflow-wrap: anywhere;
  margin: 7px 0 0;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
}

.signal-caution {
  margin: 14px 18px 0;
  padding: 10px 11px;
  border-left: 2px solid var(--amber);
  color: #c8d2d9;
  background: rgba(244, 185, 66, 0.07);
  font-size: 11px;
  line-height: 1.6;
}

.trade-ticket {
  min-height: 0;
  padding-bottom: 14px;
}

.trade-ticket-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.trade-ticket-header span,
.trade-ticket-header strong {
  display: block;
}

.trade-ticket-header span {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
}

.trade-ticket-header strong {
  font-size: 13px;
}

.secondary-command,
.primary-command,
.text-command,
.execution-action {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.secondary-command {
  padding: 0 13px;
  color: var(--text);
  background: var(--surface-2);
}

.secondary-command:hover,
.execution-action:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.primary-command {
  padding: 0 15px;
  border-color: var(--cyan);
  color: #041013;
  background: var(--cyan);
}

.primary-command.buy {
  border-color: var(--green);
  background: var(--green);
}

.primary-command.sell {
  border-color: var(--red);
  color: #fff;
  background: var(--red);
}

.primary-command:disabled,
.secondary-command:disabled,
.execution-action:disabled {
  cursor: not-allowed;
  opacity: 0.36;
}

.text-command {
  min-height: 28px;
  padding: 0;
  border: 0;
  color: var(--cyan);
  background: transparent;
  font-size: 11px;
  text-align: left;
}

#orderForm {
  padding: 14px 16px 0;
}

.order-side-control,
.order-type-control {
  display: grid;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.order-side-control {
  grid-template-columns: 1fr 1fr;
  margin-bottom: 10px;
}

.order-side-control button {
  height: 38px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.order-side-control .buy {
  color: var(--green);
}

.order-side-control .sell {
  color: var(--red);
}

.order-side-control .buy.active {
  color: #04100b;
  background: var(--green);
}

.order-side-control .sell.active {
  color: #fff;
  background: var(--red);
}

.order-type-control {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 12px;
}

.order-type-control button {
  min-height: 32px;
  font-size: 11px;
}

.order-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.order-form-grid label,
.dialog-field,
.position-action-fields label {
  display: block;
  min-width: 0;
}

.order-form-grid label > span,
.dialog-field > span,
.position-action-fields label > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
}

.order-form-grid input,
.dialog-field input,
.position-action-fields input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  outline: none;
  color: var(--text);
  background: #091017;
  font-family: "SFMono-Regular", Consolas, monospace;
}

.order-form-grid input:focus,
.dialog-field input:focus,
.position-action-fields input:focus {
  border-color: var(--cyan);
}

.order-check-result {
  min-height: 64px;
  margin: 8px 0 12px;
  padding: 10px 11px;
  border-left: 2px solid var(--amber);
  color: var(--muted);
  background: rgba(244, 185, 66, 0.06);
  font-size: 10px;
  line-height: 1.55;
}

.order-check-result.valid {
  border-left-color: var(--green);
  color: #c7f7df;
  background: rgba(25, 230, 140, 0.05);
}

.order-check-result.error {
  border-left-color: var(--red);
  color: #ffc1cc;
  background: rgba(255, 77, 109, 0.05);
}

.trade-ticket-actions {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 8px;
}

.execution-panel {
  margin-top: 16px;
  overflow: hidden;
}

.execution-heading {
  gap: 16px;
}

.account-strip {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  color: var(--muted);
  font-size: 10px;
}

.account-strip strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.icon-button.compact {
  width: 30px;
  height: 30px;
  font-size: 17px;
  line-height: 28px;
}

.execution-tabs {
  display: flex;
  min-height: 40px;
  border-bottom: 1px solid var(--line-soft);
}

.execution-tabs button {
  min-width: 150px;
  padding: 0 18px;
  font-size: 11px;
}

.execution-tabs span {
  margin-left: 5px;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
}

.execution-list {
  min-height: 118px;
}

.execution-list.locked-state,
.execution-empty {
  display: grid;
  min-height: 118px;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.execution-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) repeat(4, minmax(90px, 0.8fr)) minmax(210px, 1.3fr);
  gap: 12px;
  align-items: center;
  min-height: 78px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.execution-row:last-child {
  border-bottom: 0;
}

.execution-row strong,
.execution-row span {
  display: block;
}

.execution-row .instrument {
  font-size: 13px;
}

.execution-row .instrument span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.execution-metric {
  min-width: 0;
  color: var(--muted);
  font-size: 10px;
}

.execution-metric strong {
  overflow: hidden;
  margin-top: 5px;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  text-overflow: ellipsis;
}

.positive {
  color: var(--green) !important;
}

.negative {
  color: var(--red) !important;
}

.execution-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.execution-action {
  min-height: 30px;
  padding: 0 9px;
  color: var(--text);
  background: var(--surface-2);
  font-size: 10px;
}

.execution-action.danger {
  border-color: rgba(255, 77, 109, 0.36);
  color: var(--red);
}

.terminal-dialog {
  width: min(520px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

.terminal-dialog::backdrop {
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(4px);
}

.terminal-dialog form > header,
.terminal-dialog form > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
}

.terminal-dialog form > header {
  border-bottom: 1px solid var(--line-soft);
}

.terminal-dialog form > footer {
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid var(--line-soft);
}

.terminal-dialog h2,
.terminal-dialog p {
  margin: 0;
}

.terminal-dialog header p {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
}

.terminal-dialog h2 {
  font-size: 16px;
}

.dialog-close {
  width: 32px;
  height: 32px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 22px;
}

.dialog-field,
.dialog-note,
.dialog-error,
.confirm-order-summary,
.confirm-check,
.position-action-fields {
  margin: 16px 18px;
}

.dialog-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.dialog-error {
  min-height: 18px;
  color: var(--red);
  font-size: 11px;
}

.confirm-order-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line-soft);
}

.confirm-order-summary div {
  min-width: 0;
  padding: 12px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.confirm-order-summary div:nth-child(even) {
  border-right: 0;
}

.confirm-order-summary div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.confirm-order-summary span,
.confirm-order-summary strong {
  display: block;
}

.confirm-order-summary span {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
}

.confirm-order-summary strong {
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.confirm-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: #cbd6dc;
  font-size: 11px;
  line-height: 1.5;
}

.confirm-check input {
  margin: 2px 0 0;
}

.position-action-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.analysis-band {
  margin-top: 16px;
}

.section-heading > span {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11px;
}

.timeframe-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.timeframe-item {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 92px;
  padding: 14px 18px;
  border-right: 1px solid var(--line-soft);
}

.timeframe-item:last-child {
  border-right: 0;
}

.timeframe-name {
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 17px;
  font-weight: 750;
}

.bias-label {
  display: inline-block;
  min-width: 48px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 800;
}

.bias-label.buy {
  color: var(--green);
}

.bias-label.sell {
  color: var(--red);
}

.bias-label.neutral {
  color: var(--amber);
}

.timeframe-meta {
  color: var(--muted);
  font-size: 11px;
}

.score-gauge {
  position: relative;
  width: 90px;
  height: 5px;
  background: #1a252e;
}

.score-gauge::after {
  position: absolute;
  top: -3px;
  bottom: -3px;
  left: 50%;
  width: 1px;
  background: #50606c;
  content: "";
}

.score-gauge i {
  position: absolute;
  top: 0;
  width: 0;
  height: 100%;
}

.score-gauge i.buy {
  left: 50%;
  background: var(--green);
}

.score-gauge i.sell {
  right: 50%;
  background: var(--red);
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(440px, 0.95fr);
  gap: 16px;
  margin-top: 16px;
}

.factor-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.factor-item {
  position: relative;
  min-height: 82px;
  padding: 15px 16px 14px 20px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.factor-item:nth-child(even) {
  border-right: 0;
}

.factor-item:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.factor-item::before {
  position: absolute;
  top: 18px;
  left: 9px;
  width: 3px;
  height: 22px;
  background: var(--amber);
  content: "";
}

.factor-item.buy::before {
  background: var(--green);
}

.factor-item.sell::before {
  background: var(--red);
}

.factor-item strong,
.factor-item span {
  display: block;
}

.factor-item strong {
  margin-bottom: 7px;
  font-size: 12px;
}

.factor-item span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.history-table-wrap {
  max-height: 328px;
  overflow: auto;
}

.history-panel table {
  width: 100%;
  border-collapse: collapse;
}

.history-panel th,
.history-panel td {
  height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  font-size: 11px;
  white-space: nowrap;
}

.history-panel th {
  position: sticky;
  z-index: 2;
  top: 0;
  color: var(--muted);
  background: var(--surface);
  font-weight: 500;
}

.history-panel td {
  font-family: "SFMono-Regular", Consolas, monospace;
}

.history-panel tbody tr:last-child td {
  border-bottom: 0;
}

.history-side {
  font-family: inherit;
  font-weight: 800;
}

.history-side.buy {
  color: var(--green);
}

.history-side.sell {
  color: var(--red);
}

.empty-row td {
  height: 160px;
  color: var(--muted);
  text-align: center;
}

.terminal-footer {
  justify-content: space-between;
  min-height: 48px;
  padding: 0 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #06090c;
  font-size: 10px;
}

.terminal-footer a {
  color: var(--muted);
  text-decoration: none;
}

.terminal-footer a:hover {
  color: var(--cyan);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1100px) {
  .market-strip {
    grid-template-columns: 180px 1fr;
    gap: 18px;
    padding: 18px 0;
  }

  .quote-details {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .market-time {
    position: absolute;
    right: 28px;
    margin-top: 88px;
  }

  .board-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .signal-panel {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
  }

  .signal-panel > header {
    grid-column: 1 / -1;
  }

  .signal-call,
  .confidence {
    grid-column: 1;
  }

  .trade-levels,
  .signal-caution {
    grid-column: 2;
  }

  .trade-levels {
    grid-row: 2 / span 2;
    margin-top: 18px;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .execution-row {
    grid-template-columns: minmax(150px, 1fr) repeat(3, minmax(88px, 0.7fr)) minmax(190px, 1fr);
  }

  .execution-row .execution-metric:nth-of-type(4) {
    display: none;
  }
}

@media (max-width: 760px) {
  .terminal-header {
    position: static;
    flex-wrap: wrap;
    min-height: 62px;
    padding: 0 14px;
  }

  .terminal-nav {
    order: 3;
    width: 100%;
    min-height: 38px;
    justify-content: center;
  }

  .header-status {
    gap: 8px;
  }

  #clock {
    display: none;
  }

  .mode-badge {
    padding: 5px 7px;
    font-size: 10px;
  }

  main {
    padding: 12px 12px 22px;
  }

  .market-strip {
    grid-template-columns: 1fr 1fr;
    gap: 13px;
    min-height: 0;
  }

  .market-identity h1 {
    font-size: 15px;
  }

  .quote-primary {
    justify-content: flex-end;
  }

  .quote-primary strong {
    font-size: 28px;
  }

  .quote-details {
    grid-template-columns: repeat(2, 1fr);
  }

  .quote-details div {
    padding: 9px 12px;
    border-top: 1px solid var(--line-soft);
  }

  .market-time {
    display: none;
  }

  .panel-header {
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }

  .chart-header-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .timeframe-control {
    width: 100%;
  }

  .timeframe-control button {
    min-width: 0;
    flex: 1;
  }

  .chart-wrap {
    min-height: 460px;
    aspect-ratio: 4 / 5;
  }

  .chart-toolbar {
    width: 100%;
  }

  .indicator-toggle {
    flex: 1;
  }

  .chart-legend {
    gap: 10px;
    overflow-x: auto;
    white-space: nowrap;
  }

  .viewport-status {
    display: none;
  }

  .chart-ohlc {
    max-width: calc(100% - 18px);
    overflow: hidden;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .signal-panel {
    display: block;
  }

  .order-form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .trade-levels,
  .signal-caution {
    margin-top: 14px;
  }

  .signal-call span {
    font-size: 44px;
  }

  .timeframe-grid {
    grid-template-columns: 1fr;
  }

  .timeframe-item {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .timeframe-item:last-child {
    border-bottom: 0;
  }

  .factor-list {
    grid-template-columns: 1fr;
  }

  .factor-item,
  .factor-item:nth-child(even),
  .factor-item:nth-last-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .factor-item:last-child {
    border-bottom: 0;
  }

  .history-table-wrap {
    max-width: calc(100vw - 26px);
  }

  .execution-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .account-strip {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(3, 1fr) auto;
    gap: 8px;
  }

  .execution-tabs button {
    min-width: 0;
    flex: 1;
  }

  .execution-row {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 14px;
  }

  .execution-row .instrument,
  .execution-row .execution-actions {
    grid-column: 1 / -1;
  }

  .execution-row .execution-metric:nth-of-type(4) {
    display: block;
  }

  .execution-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .position-action-fields,
  .confirm-order-summary {
    grid-template-columns: 1fr;
  }

  .confirm-order-summary div,
  .confirm-order-summary div:nth-child(even),
  .confirm-order-summary div:nth-last-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .confirm-order-summary div:last-child {
    border-bottom: 0;
  }

  .terminal-footer {
    padding: 0 14px;
  }

  .terminal-footer span:first-child {
    display: none;
  }

  .latency-badge {
    display: none;
  }
}
