:root {
  color-scheme: light dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0c1118;
  color: #e6edf5;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #0c1118; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }
.app-header { height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; border-bottom: 1px solid #283241; background: #111822; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark { width: 27px; height: 27px; display: grid; place-items: center; background: #2867d6; color: #fff; font-size: 11px; font-weight: 800; }
.run-state { color: #91a0b2; font-size: 12px; }
.run-state strong { color: #21b784; }

.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100vh - 54px); }
.parameters { padding: 16px; border-right: 1px solid #283241; background: #101720; }
.parameters h2 { margin: 0 0 15px; font-size: 14px; }
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field label, .field-label { color: #9aa8b7; font-size: 11px; }
input, select { width: 100%; height: 34px; padding: 0 9px; border: 1px solid #344152; border-radius: 4px; background: #151e29; color: #e6edf5; }
.check { display: flex; align-items: center; gap: 8px; min-height: 30px; color: #cbd5df; font-size: 12px; }
.check input { width: auto; height: auto; accent-color: #2867d6; }
.separator { height: 1px; margin: 13px 0; background: #26313f; }
.run-button { width: 100%; height: 40px; border: 0; border-radius: 4px; background: #2867d6; color: #fff; font-weight: 700; }
.run-button:disabled { cursor: progress; opacity: .65; }
.error-box { margin-top: 10px; padding: 9px; border: 1px solid #713c45; background: #2a171b; color: #ff9ca5; font-size: 11px; }

.workspace { min-width: 0; padding: 16px; }
.metrics { display: grid; grid-template-columns: repeat(6, minmax(100px, 1fr)); gap: 8px; margin-bottom: 10px; }
.metric { min-width: 0; padding: 10px 11px; border: 1px solid #283342; background: #121a24; }
.metric small { display: block; margin-bottom: 4px; color: #91a0b1; font-size: 10px; }
.metric strong { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 17px; font-variant-numeric: tabular-nums; }
.positive { color: #21b784 !important; }
.negative { color: #ef5963 !important; }

.panel { min-width: 0; border: 1px solid #283342; background: #121a24; }
.panel-header { min-height: 39px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 11px; border-bottom: 1px solid #273240; }
.panel-header h2 { margin: 0; font-size: 12px; }
.panel-header span { color: #8d9baa; font-size: 10px; }
.navigator { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 10px; border-bottom: 1px solid #273240; background: #101720; }
.nav-buttons, .status-filter { display: flex; align-items: center; gap: 6px; }
.view-controls { display: flex; align-items: center; gap: 12px; }
.timezone-control { display: flex; align-items: center; gap: 6px; color: #9aa8b7; font-size: 10px; }
.timezone-control select { width: 135px; height: 30px; padding: 0 7px; font-size: 11px; }
.secondary-button, .filter-button { height: 30px; padding: 0 10px; border: 1px solid #344152; border-radius: 4px; background: #151e29; color: #e6edf5; font-size: 11px; }
.secondary-button:disabled { opacity: .4; cursor: default; }
.filter-button.active { border-color: #2867d6; background: #172a42; color: #8bb8ff; }
.divergence-count { min-width: 95px; text-align: center; color: #aab6c4; font-size: 11px; font-variant-numeric: tabular-nums; }

.indicator-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 16px; min-height: 37px; padding: 6px 10px; border-bottom: 1px solid #273240; font-size: 10px; font-variant-numeric: tabular-nums; }
.indicator-strip span { white-space: nowrap; color: #97a5b4; }
.indicator-strip strong { margin-left: 4px; color: #e6edf5; }
.indicator-strip .ema20 { color: #f0a22e; }
.indicator-strip .ema50 { color: #4d8df1; }
.indicator-strip .macd { color: #e6b450; }
.indicator-strip .signal-line { color: #a477eb; }

.chart-scroll { position: relative; overflow-x: auto; overflow-y: hidden; min-height: 705px; scrollbar-color: #536274 transparent; scrollbar-width: thin; }
.chart-stage { min-width: 980px; }
.chart-scroll svg { display: block; }
.indicator-chart { border-top: 1px solid #344152; }
.chart-bg { fill: #121a24; }
.chart-grid { stroke: #222d3a; stroke-width: 1; }
.time-grid { opacity: .7; }
.axis-label { fill: #8d9aaa; font-size: 10px; }
.pane-title { fill: #aab6c4; font-size: 10px; font-weight: 700; }
.candle-up { fill: #13a37b; stroke: #13a37b; }
.candle-down { fill: #e24a52; stroke: #e24a52; }
.ema20-path { fill: none; stroke: #f0a22e; stroke-width: 1.6; }
.ema50-path { fill: none; stroke: #4d8df1; stroke-width: 1.6; }
.rsi-path { fill: none; stroke: #9a72df; stroke-width: 1.5; }
.rsi-divergence-long { stroke: #21b784; stroke-width: 2.4; }
.rsi-divergence-short { stroke: #ef5963; stroke-width: 2.4; }
.rsi-divergence-point { fill: #a477eb; stroke: #fff; stroke-width: 1.2; }
.rsi-point-label, .rsi-delta-label { fill: #e6edf5; font-size: 10px; font-weight: 700; }
.rsi-delta-label { paint-order: stroke; stroke: #121a24; stroke-width: 4px; stroke-linejoin: round; }
.macd-path { fill: none; stroke: #e6b450; stroke-width: 1.4; }
.macd-average-path { fill: none; stroke: #a477eb; stroke-width: 1.4; }
.rsi-cutoff { stroke: #49576a; stroke-width: 1; stroke-dasharray: 4 4; }
.macd-long-cutoff { stroke: #21b784; stroke-width: 1.2; stroke-dasharray: 6 4; }
.macd-short-cutoff { stroke: #ef5963; stroke-width: 1.2; stroke-dasharray: 6 4; }
.cutoff-label { font-size: 10px; font-weight: 700; }
.cutoff-label.long { fill: #21b784; }
.cutoff-label.short { fill: #ef5963; }
.time-tick { stroke: #718197; stroke-width: 1; }
.time-label { fill: #9aa8b7; font-size: 10px; }
.level-entry { stroke: #4d8df1; stroke-width: 1.5; stroke-dasharray: 6 4; }
.level-stop { stroke: #ef5963; stroke-width: 1.5; }
.level-target { stroke: #21b784; stroke-width: 1.5; }
.point-label { fill: #fff; font-size: 10px; font-weight: 700; }
.point-hit { fill: transparent; stroke: transparent; stroke-width: 20; cursor: crosshair; }
.crosshair { stroke: #718197; stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.cursor-time { pointer-events: none; }
.cursor-time rect { fill: #dce7f6; stroke: #4d8df1; stroke-width: 1; }
.cursor-time text { fill: #101720; font-size: 11px; font-weight: 700; }

.point-tooltip { position: fixed; z-index: 50; width: 250px; padding: 10px; border: 1px solid #3c495a; background: #18222e; box-shadow: 0 10px 28px rgba(0,0,0,.42); pointer-events: none; }
.point-tooltip h3 { margin: 0 0 7px; font-size: 12px; }
.tooltip-row { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; font-size: 11px; }
.tooltip-row span:first-child { color: #97a5b4; }
.tooltip-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; }

.below-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr); gap: 10px; margin-top: 10px; }
.debug-panel { min-width: 0; }
.trace-list { max-height: 310px; overflow: auto; }
.trace-row { display: grid; grid-template-columns: 75px minmax(135px,1fr) minmax(120px,1fr) minmax(120px,1fr) 70px; gap: 8px; align-items: center; padding: 7px 10px; border-bottom: 1px solid #24303d; font-size: 11px; }
.trace-row.header { color: #94a1af; background: #101720; font-size: 10px; }
.trace-stage { color: #94a1af; }
.trace-result { font-weight: 700; }
.reason-list { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 10px; border-bottom: 1px solid #24303d; }
.reason { padding: 3px 6px; border: 1px solid #713c45; background: #2a171b; color: #ff9ca5; font-size: 10px; }
.accepted-note { color: #21b784; font-size: 11px; }

.trades-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { color: #94a1af; background: #101720; font-weight: 600; text-align: left; }
th, td { padding: 8px 9px; border-bottom: 1px solid #24303d; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.active { background: #172a42; }
.direction-long { color: #21b784; font-weight: 700; }
.direction-short { color: #ef5963; font-weight: 700; }
.loading { min-height: 520px; display: grid; place-items: center; color: #91a0b2; }

@media (max-width: 1050px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .below-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .parameters { border-right: 0; border-bottom: 1px solid #283241; }
  .parameter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
  .workspace { padding: 10px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .navigator { align-items: flex-start; flex-direction: column; }
  .view-controls { align-items: flex-start; flex-direction: column; }
  .indicator-strip { align-items: flex-start; flex-direction: column; }
  .trace-row { min-width: 650px; }
  .trace-list { overflow-x: auto; }
}
