:root {
  color-scheme: dark;
  --bg: #080b0c;
  --surface: #111719;
  --surface-2: #151d21;
  --surface-3: #0f1613;
  --line: #25323a;
  --text: #eef4ef;
  --muted: #9dafb1;
  --green: #45d483;
  --red: #ef6262;
  --amber: #f2b84b;
  --cyan: #66d9ef;
  --blue: #7aa7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #0d1214 0%, var(--bg) 52%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
a {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar,
.metric-strip,
.equity-panel,
.workspace,
.lower-grid {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 0 20px;
}

.eyebrow,
.label {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.7rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.45rem;
  letter-spacing: 0;
}

.control-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.segment {
  min-width: 72px;
  min-height: 38px;
  border: 0;
  color: var(--muted);
  background: transparent;
}

.segment.active {
  color: #06100a;
  background: var(--green);
  font-weight: 800;
}

.toggle-row,
.status-pill,
.tool-link,
.secondary-button,
.danger-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 750;
}

.status-pill {
  color: var(--muted);
  cursor: pointer;
}

.status-pill.locked {
  border-color: rgba(242, 184, 75, 0.6);
  color: #ffe0a3;
}

.status-pill.live {
  border-color: rgba(69, 212, 131, 0.6);
  color: var(--green);
}

.status-pill.off {
  border-color: rgba(239, 98, 98, 0.55);
  color: #ffb8b8;
}

.tool-link {
  text-decoration: none;
}

.secondary-button {
  cursor: pointer;
}

.danger-button {
  border-color: rgba(239, 98, 98, 0.6);
  color: #ffb8b8;
}

.danger-button.active {
  border-color: rgba(69, 212, 131, 0.62);
  color: var(--green);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric-strip div,
.panel,
.market-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 23, 25, 0.92);
}

.metric-strip div {
  min-height: 72px;
  padding: 14px;
}

.metric-strip span,
.market-stats span,
dt {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric-strip strong {
  display: block;
  margin-top: 8px;
  font-size: 1.2rem;
  letter-spacing: 0;
}

.good {
  color: var(--green);
}

.bad {
  color: var(--red);
}

.muted-cell {
  color: var(--muted);
}

.equity-panel {
  margin-bottom: 12px;
}

.equity-summary {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.equity-summary span {
  min-height: 40px;
  border: 1px solid #223039;
  border-radius: 6px;
  padding: 8px 10px;
  background: #0c1214;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.equity-summary b {
  margin-left: 6px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.equity-chart-wrap {
  position: relative;
}

.equity-chart {
  display: block;
  width: 100%;
  height: 220px;
}

.equity-chart-value {
  position: absolute;
  right: 14px;
  top: 14px;
  min-width: 150px;
  border: 1px solid #24323a;
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(7, 11, 13, 0.82);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.equity-chart-value span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.equity-chart-value strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
  align-items: start;
}

.workspace > * {
  min-width: 0;
}

.primary-stack {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
  width: auto;
}

.primary-stack > * {
  min-width: 0;
}

.market-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
  min-width: 0;
}

.market-card {
  min-height: 560px;
  height: 100%;
  padding: 14px;
  background: var(--surface-2);
  align-self: stretch;
  display: flex;
  flex-direction: column;
}

.market-card.active {
  background: var(--surface-3);
  border-color: rgba(69, 212, 131, 0.42);
}

.market-head,
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.market-head-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.symbol-tile-toggle {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}

.symbol-tile-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.symbol-tile-toggle span {
  position: relative;
  width: 34px;
  height: 18px;
  border: 1px solid rgba(69, 212, 131, 0.46);
  border-radius: 999px;
  background: rgba(69, 212, 131, 0.22);
}

.symbol-tile-toggle span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  transition: left 120ms ease, background 120ms ease;
}

.symbol-tile-toggle input:not(:checked) + span {
  border-color: rgba(239, 98, 98, 0.5);
  background: rgba(239, 98, 98, 0.14);
}

.symbol-tile-toggle input:not(:checked) + span::after {
  left: 4px;
  background: var(--red);
}

.symbol-tile-toggle input:focus-visible + span {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.market-card.symbol-disabled {
  border-color: rgba(239, 98, 98, 0.36);
  opacity: 0.72;
}

.market-card.symbol-disabled canvas,
.market-card.symbol-disabled .pressure,
.market-card.symbol-disabled .order-flow {
  filter: grayscale(0.9);
}

.bias {
  min-width: 70px;
  border-radius: 999px;
  padding: 7px 10px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.bias.long {
  color: #041008;
  background: var(--green);
}

.bias.short {
  color: #1d0707;
  background: var(--red);
}

.bias.flat {
  color: #160f00;
  background: var(--amber);
}

.bias.off {
  color: #f4c5c5;
  background: rgba(239, 98, 98, 0.18);
  border: 1px solid rgba(239, 98, 98, 0.48);
}

canvas {
  width: 100%;
  height: 132px;
  margin-top: 12px;
  border: 1px solid #1f2c31;
  border-radius: 6px;
  background: #080c0e;
}

.market-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.market-stats span {
  min-height: 54px;
  border: 1px solid #223039;
  border-radius: 6px;
  padding: 9px;
  background: #0c1214;
}

.market-stats b {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 0.96rem;
  overflow-wrap: anywhere;
}

.pressure {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  height: 12px;
  margin-top: 12px;
}

.pressure span {
  display: block;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(69, 212, 131, 0.18), var(--green));
  transform-origin: left center;
}

.pressure span + span {
  background: linear-gradient(90deg, var(--red), rgba(239, 98, 98, 0.18));
  transform-origin: right center;
}

.order-flow {
  margin-top: 12px;
  border: 1px solid #223039;
  border-radius: 6px;
  padding: 10px;
  background: #0a1012;
}

.flow-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.flow-head span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.flow-head strong {
  font-size: 0.86rem;
  font-weight: 850;
}

.flow-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.flow-grid span {
  min-height: 50px;
  border: 1px solid #1f2c31;
  border-radius: 6px;
  padding: 8px;
  background: #0c1214;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 750;
}

.flow-grid b {
  display: block;
  margin-top: 5px;
  color: var(--text);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.imbalance-track {
  position: relative;
  height: 12px;
  margin-top: 12px;
  border: 1px solid #223039;
  border-radius: 999px;
  overflow: hidden;
  background: #070b0d;
}

.imbalance-track::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: #314149;
  content: "";
}

.imbalance-track i {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 50%;
  min-width: 4px;
  border-radius: 999px;
  background: var(--green);
  transition:
    width 180ms ease,
    background 180ms ease;
}

.imbalance-track i.negative {
  right: 50%;
  left: auto;
  background: var(--red);
}

.plan {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
  min-height: 4.5em;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.side-stack {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
  width: 100%;
}

.side-stack > *,
.settings-form,
.settings-form label,
.settings-form fieldset,
.settings-grid,
.settings-grid > * {
  min-width: 0;
}

.settings-panel {
  min-height: 0;
}

#settings-save-state.good {
  color: var(--green);
}

#settings-save-state.warn {
  color: var(--amber);
}

#settings-save-state.bad {
  color: var(--red);
}

.settings-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.settings-form label,
.settings-form fieldset {
  display: grid;
  gap: 7px;
  margin: 0;
  border: 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.settings-form select,
.settings-form input[type="number"],
.settings-form input[type="search"],
.settings-form input[type="text"] {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid #2b3a42;
  border-radius: 8px;
  background: #070b0d;
  color: var(--text);
  padding: 0 10px;
}

.settings-form select:disabled {
  color: var(--muted);
  opacity: 1;
}

.settings-form label.disabled {
  opacity: 0.58;
}

.settings-form label.disabled input,
.settings-form label.disabled select {
  cursor: not-allowed;
}

.backtest-picker small {
  min-height: 14px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-transform: none;
}

.backtest-picker small.good {
  color: var(--green);
}

.backtest-picker small.warn {
  color: var(--amber);
}

.backtest-picker small.bad {
  color: var(--red);
}

.range-row b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.settings-form input[type="range"] {
  width: 100%;
  min-width: 0;
  accent-color: var(--green);
}

.settings-form fieldset {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.settings-grid fieldset.settings-days {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin: 2px 0 4px;
}

.settings-form legend {
  grid-column: 1 / -1;
  padding: 0;
  margin-bottom: 1px;
}

.settings-form fieldset label {
  min-height: 36px;
  border: 1px solid #2b3a42;
  border-radius: 8px;
  background: #070b0d;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.settings-form fieldset label input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.settings-form fieldset label span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0;
}

.settings-form fieldset label:has(input:checked) {
  border-color: rgba(69, 212, 131, 0.66);
  background: rgba(69, 212, 131, 0.18);
  box-shadow: inset 0 0 0 1px rgba(69, 212, 131, 0.16);
}

.settings-form fieldset label:has(input:checked) span {
  color: var(--text);
}

.settings-form fieldset label:has(input:focus-visible) {
  outline: 2px solid rgba(69, 212, 131, 0.7);
  outline-offset: 2px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-subhead {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.settings-subhead small,
.settings-grid label span small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
  text-transform: none;
}

.settings-form label.toggle-row {
  min-height: 40px;
  border: 1px solid #2b3a42;
  border-radius: 8px;
  background: #070b0d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px;
}

.settings-form label.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.panel {
  padding: 16px;
}

.engine-panel {
  min-height: 292px;
}

.pipeline {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.pipe-step {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px solid #233138;
  border-radius: 6px;
  padding: 8px;
  background: #0c1214;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(69, 212, 131, 0.5);
  justify-self: center;
}

.pipe-step.warn .dot {
  background: var(--amber);
  box-shadow: 0 0 12px rgba(242, 184, 75, 0.45);
}

.pipe-step.stop .dot {
  background: var(--red);
  box-shadow: 0 0 12px rgba(239, 98, 98, 0.45);
}

.pipe-step strong {
  display: block;
  font-size: 0.9rem;
}

.pipe-step span {
  color: var(--muted);
  font-size: 0.78rem;
}

.risk-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 0;
}

.risk-grid div,
.execution-grid div {
  min-height: 72px;
  border: 1px solid #233138;
  border-radius: 6px;
  padding: 10px;
  background: #0c1214;
}

.risk-grid dd,
.execution-grid dd {
  margin: 8px 0 0;
  font-size: 1.15rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.execution-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 0;
}

.execution-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.execution-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.execution-actions .secondary-button,
.execution-actions .danger-button {
  justify-content: center;
  cursor: pointer;
}

.mechanics-panel {
  display: grid;
  gap: 12px;
}

.mechanics-copy {
  display: grid;
  gap: 10px;
}

.mechanics-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.mechanics-copy b {
  color: var(--text);
  font-weight: 850;
}

.position-ledger-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.position-ledger-actions .danger-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.72rem;
  white-space: nowrap;
}

.danger-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
  gap: 12px;
  margin-top: 0;
  min-width: 0;
}

.lower-grid > * {
  min-width: 0;
}

.position-ledger-panel,
.trade-ledger-panel,
.signal-feed-panel {
  margin-top: 0;
}

.pnl-rollup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.pnl-rollup-tile {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 23, 25, 0.92);
  padding: 14px;
  display: grid;
  align-content: center;
  gap: 5px;
}

.pnl-rollup-tile span,
.pnl-rollup-tile small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.pnl-rollup-tile strong {
  font-size: 1.35rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.profit-calendar-panel {
  margin-bottom: 12px;
}

.profit-calendar-head {
  align-items: center;
}

.profit-calendar-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  background: #0b1215;
}

.profit-calendar-controls button {
  width: 30px;
  height: 30px;
  border: 1px solid #33434b;
  border-radius: 6px;
  background: #070b0d;
  color: var(--text);
  cursor: pointer;
  font-weight: 850;
}

.profit-calendar-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.profit-calendar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  flex-wrap: wrap;
}

.profit-calendar-meta-primary {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.profit-calendar-meta-primary span:first-child {
  font-size: 1rem;
  font-weight: 900;
}

.profit-calendar-scroll {
  overflow-x: auto;
  padding-bottom: 2px;
}

.profit-calendar-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(94px, 1fr));
  gap: 6px;
  min-width: 760px;
}

.profit-calendar-header {
  margin-bottom: 6px;
}

.profit-calendar-cell {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10181b;
  padding: 7px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}

.profit-calendar-cell.header-cell {
  min-height: auto;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-align: center;
  padding: 0 4px;
}

.profit-calendar-cell.muted {
  opacity: 0.42;
}

.profit-calendar-cell.today {
  border-color: rgba(102, 217, 239, 0.72);
  box-shadow: inset 0 0 0 1px rgba(102, 217, 239, 0.24);
}

.profit-calendar-cell.win {
  border-color: rgba(69, 212, 131, 0.26);
}

.profit-calendar-cell.loss {
  border-color: rgba(239, 98, 98, 0.28);
}

.profit-calendar-total {
  justify-content: center;
}

.profit-calendar-day {
  align-self: flex-end;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  opacity: 0.94;
}

.profit-calendar-pnl {
  margin-top: auto;
  font-size: 0.84rem;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profit-calendar-trades {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.position-ledger-scroll,
.trade-ledger-scroll,
.signal-feed-scroll {
  max-height: 430px;
}

.table-scroll.position-ledger-scroll table {
  width: 100%;
  min-width: 1120px;
}

.table-scroll.trade-ledger-scroll table {
  width: 100%;
  min-width: 1120px;
}

.table-scroll.signal-feed-scroll table {
  width: 100%;
  min-width: 1040px;
}

.position-ledger-table,
.trade-ledger-table,
.signal-feed-table {
  table-layout: auto;
}

.position-ledger-table th,
.position-ledger-table td,
.trade-ledger-table th,
.trade-ledger-table td,
.signal-feed-table th,
.signal-feed-table td {
  white-space: nowrap;
}

.position-ledger-table td,
.trade-ledger-table td,
.signal-feed-table td {
  font-variant-numeric: tabular-nums;
}

.position-ledger-table thead th,
.trade-ledger-table thead th,
.signal-feed-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #0b1215;
}

.position-ledger-table tbody tr:hover,
.trade-ledger-table tbody tr:hover,
.signal-feed-table tbody tr:hover {
  background: rgba(69, 212, 131, 0.08);
}

.signal-feed-table .reason-cell {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.decision-pill {
  display: inline-flex;
  min-width: 92px;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.decision-pill.accepted {
  border-color: rgba(69, 212, 131, 0.42);
  color: var(--green);
}

.decision-pill.rejected,
.decision-pill.skipped {
  border-color: rgba(239, 98, 98, 0.34);
  color: #ffb8b8;
}

.position-owner {
  display: inline-flex;
  margin-left: 6px;
  border: 1px solid #2b3a42;
  border-radius: 999px;
  padding: 2px 6px;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.position-select {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

.empty-trade-row td {
  color: var(--muted);
}

.backtests-shell h1 {
  font-size: clamp(2.4rem, 6vw, 5.4rem);
}

.backtest-controls-panel,
.backtest-table-panel {
  margin-bottom: 12px;
}

.backtest-controls-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.6fr) minmax(180px, 0.8fr) minmax(100px, 0.4fr);
  gap: 10px;
}

.backtest-controls-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.backtest-controls-grid input,
.backtest-controls-grid select {
  min-height: 42px;
  width: 100%;
  border: 1px solid #2b3a42;
  border-radius: 8px;
  background: #070b0d;
  color: var(--text);
  padding: 0 10px;
}

.table-note {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  max-height: min(72vh, 820px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #526b75 #10191d;
  scrollbar-gutter: stable both-edges;
  scrollbar-width: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 12px;
  border: 1px solid #223039;
  border-radius: 8px;
}

.table-scroll::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.table-scroll::-webkit-scrollbar-track {
  background: #10191d;
}

.table-scroll::-webkit-scrollbar-thumb {
  background: #526b75;
  border: 2px solid #10191d;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid #223039;
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

th {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.table-scroll table {
  width: max-content;
  min-width: 1260px;
  margin-top: 0;
}

.backtest-table {
  table-layout: auto;
}

.backtest-table th,
.backtest-table td {
  padding: 10px 8px;
  white-space: nowrap;
}

.backtest-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0b1215;
}

.backtest-table td:nth-child(3) {
  min-width: 96px;
}

.backtest-table td:nth-child(4) {
  min-width: 176px;
}

.backtest-table td:nth-child(6),
.backtest-table td:nth-child(7),
.backtest-table td:nth-child(8),
.backtest-table td:nth-child(9),
.backtest-table td:nth-child(10),
.backtest-table td:nth-child(11),
.backtest-table td:nth-child(12),
.backtest-table td:nth-child(13),
.backtest-table td:nth-child(14),
.backtest-table td:nth-child(15),
.backtest-table td:nth-child(16) {
  min-width: 96px;
}

.backtest-table td:nth-child(6),
.backtest-table td:nth-child(7) {
  min-width: 128px;
}

.backtest-table td:nth-child(n + 13) {
  min-width: 104px;
}

.backtest-table tbody tr {
  cursor: pointer;
}

.backtest-table tbody tr:hover,
.backtest-table tbody tr.active {
  background: rgba(69, 212, 131, 0.08);
}

.sort-button {
  width: 100%;
  border: 0;
  color: inherit;
  background: transparent;
  padding: 0;
  text-align: left;
  cursor: pointer;
  font-size: inherit;
  font-weight: 850;
  text-transform: inherit;
}

.sort-button.asc::after {
  content: " ↑";
}

.sort-button.desc::after {
  content: " ↓";
}

.warn {
  color: var(--amber);
}

.backtest-detail-body {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.metric-focus-section {
  display: grid;
  gap: 8px;
}

.metric-focus-section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.metric-focus-grid,
.metric-detail-grid {
  display: grid;
  gap: 8px;
}

.metric-focus-grid {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.metric-detail-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-height: 540px;
  overflow: auto;
}

.metric-focus-grid div,
.metric-detail-grid div {
  min-height: 62px;
  border: 1px solid #223039;
  border-radius: 6px;
  background: #0c1214;
  padding: 9px;
}

.metric-focus-grid div {
  border-color: #2a3d44;
  background: #0d1517;
}

.metric-focus-grid div.missing strong {
  color: var(--muted);
}

.metric-focus-grid span,
.metric-detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.metric-focus-grid strong,
.metric-detail-grid strong {
  display: block;
  margin-top: 7px;
  color: var(--text);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.consecutive-loss-section {
  border-top: 1px solid #223039;
  padding-top: 12px;
}

.analytics-note {
  border: 1px solid #223039;
  border-radius: 8px;
  background: #0c1214;
  padding: 12px;
}

.analytics-note strong {
  display: block;
  margin-bottom: 7px;
  color: var(--amber);
}

.analytics-note p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.analytics-note p + p {
  margin-top: 7px;
}

.analytics-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
  gap: 8px;
}

.analytics-card-grid div {
  min-height: 68px;
  border: 1px solid #2a3d44;
  border-radius: 6px;
  background: #0d1517;
  padding: 9px;
}

.analytics-card-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.analytics-card-grid strong {
  display: block;
  margin-top: 7px;
  color: var(--text);
  font-size: 0.96rem;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.analytics-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.analytics-flags span {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #2a3d44;
  border-radius: 8px;
  padding: 6px 9px;
  background: #0d1517;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.analytics-flags .red {
  border-color: rgba(239, 98, 98, 0.56);
  color: #ffb8b8;
}

.analytics-flags .yellow {
  border-color: rgba(242, 184, 75, 0.56);
  color: #ffe0a3;
}

.analytics-flags .green {
  border-color: rgba(69, 212, 131, 0.56);
  color: var(--green);
}

.analytics-subsection {
  display: grid;
  gap: 8px;
}

.analytics-subsection h4 {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.analytics-two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.analytics-two-col > div {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.analytics-table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid #223039;
  border-radius: 8px;
}

.analytics-table {
  min-width: 920px;
  margin: 0;
  table-layout: auto;
}

.analytics-table th,
.analytics-table td {
  padding: 9px 8px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.analytics-table td {
  color: var(--text);
}

.analytics-table thead th {
  position: sticky;
  top: 0;
  background: #0b1215;
}

.analytics-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.streak-bars {
  display: grid;
  gap: 7px;
  border: 1px solid #223039;
  border-radius: 8px;
  background: #0c1214;
  padding: 10px;
}

.streak-bars div {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 64px;
  align-items: center;
  gap: 9px;
  min-height: 24px;
}

.streak-bars span,
.streak-bars strong {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.streak-bars b {
  position: relative;
  display: block;
  height: 12px;
  border: 1px solid #223039;
  border-radius: 999px;
  background: #080c0e;
  overflow: hidden;
}

.streak-bars b::after {
  position: absolute;
  inset: 1px auto 1px 1px;
  width: var(--bar-width);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--red), var(--amber));
  content: "";
}

#event-log {
  min-height: 228px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

#event-log li {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 10px;
  border-bottom: 1px solid #223039;
  padding: 10px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

#event-log time {
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

.auth-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.auth-shell {
  width: min(460px, calc(100% - 28px));
}

.auth-shell.wide {
  width: min(720px, calc(100% - 28px));
}

.auth-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 23, 25, 0.96);
  padding: 24px;
}

.auth-panel h1 {
  margin-bottom: 22px;
  font-size: clamp(2rem, 9vw, 4rem);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-form input {
  min-height: 48px;
  border: 1px solid #2b3a42;
  border-radius: 8px;
  background: #070b0d;
  color: var(--text);
  padding: 0 12px;
  text-transform: none;
}

.primary-action,
.secondary-action {
  min-height: 48px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 850;
  text-align: center;
}

.primary-action {
  border-color: rgba(69, 212, 131, 0.64);
  color: #041008;
  background: var(--green);
}

.link-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.auth-divider {
  display: grid;
  place-items: center;
  margin: 18px 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-status {
  min-height: 24px;
  margin: 16px 0 0;
  color: var(--muted);
}

.auth-status.good {
  color: var(--green);
}

.auth-status.bad {
  color: var(--red);
}

.passkey-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.passkey-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.passkey-row,
.empty-state {
  border: 1px solid #223039;
  border-radius: 8px;
  background: #0c1214;
  padding: 14px;
}

.passkey-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 12px;
  align-items: center;
}

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

.passkey-row span,
.passkey-row small,
.empty-state {
  color: var(--muted);
}

.passkey-row button {
  min-height: 38px;
  border: 1px solid rgba(239, 98, 98, 0.55);
  border-radius: 8px;
  color: #ffb8b8;
  background: transparent;
  cursor: pointer;
}

@media (max-width: 1180px) {
  .workspace,
  .lower-grid,
  .backtest-controls-grid {
    grid-template-columns: 1fr;
  }

  .side-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-two-col {
    grid-template-columns: 1fr;
  }

  .metric-focus-grid {
    grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  }
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .control-strip {
    justify-content: flex-start;
  }

  .metric-strip,
  .market-board,
  .pnl-rollup-grid,
  .side-stack,
  .passkey-actions {
    grid-template-columns: 1fr;
  }

  .equity-summary {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 18px, 1480px);
    padding-top: 12px;
  }

  .backtests-shell .panel-head {
    flex-wrap: wrap;
  }

  .backtests-shell .table-note {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  h1 {
    font-size: 2.1rem;
  }

  .flow-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .equity-chart {
    height: 180px;
  }

  .equity-chart-value {
    left: 10px;
    right: 10px;
    top: 10px;
    min-width: 0;
  }

  .passkey-row {
    grid-template-columns: 1fr;
  }

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

  .metric-focus-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  th,
  td {
    padding: 10px 6px;
    font-size: 0.8rem;
  }
}
