:root {
  color-scheme: dark;
  --bg: #02030a;
  --surface: rgba(8, 13, 18, 0.88);
  --surface-2: rgba(12, 18, 24, 0.92);
  --line: rgba(202, 236, 241, 0.14);
  --line-strong: rgba(63, 224, 208, 0.48);
  --text: #edf8fa;
  --muted: #93a6ad;
  --green: #30f28a;
  --green-soft: rgba(48, 242, 138, 0.14);
  --red: #ff465e;
  --red-soft: rgba(255, 70, 94, 0.14);
  --teal: #3fe0d0;
  --blue: #65a7ff;
  --gold: #f3c969;
  --violet: #ad8cff;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.46);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: #02030a;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  overflow-x: hidden;
}

#systemBackdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

button,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.siteShell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 14px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: 46px 46px;
}

.topbar,
.dashboard {
  width: min(1540px, 100%);
  margin: 0 auto;
}

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(63, 224, 208, 0.10), transparent 34%),
    rgba(3, 7, 12, 0.84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brandMark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: #04100c;
  background:
    linear-gradient(135deg, var(--green), var(--teal) 48%, var(--gold)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.42), transparent);
  font-size: 17px;
  font-weight: 950;
  box-shadow: 0 0 34px rgba(63, 224, 208, 0.22);
}

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

.brand strong {
  font-size: 19px;
  font-weight: 950;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

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

.statusPill,
.countBadge {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #cbd5d8;
  background: rgba(255, 255, 255, 0.045);
  font-size: 12px;
  font-weight: 900;
}

.statusPill.live {
  color: var(--green);
  border-color: rgba(48, 242, 138, 0.42);
  box-shadow: 0 0 18px rgba(48, 242, 138, 0.14);
}

.statusPill.warn {
  color: #ffc6ce;
  border-color: rgba(255, 70, 94, 0.42);
}

.dashboard {
  display: grid;
  gap: 14px;
  padding-top: 14px;
}

.heroPanel,
.metricStrip,
.workbench,
.ledgerPanel,
.symbolDockPanel,
.panel,
.metricTile,
.signalPanel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.055), transparent 34%),
    var(--surface);
  box-shadow: var(--shadow);
}

.heroPanel {
  min-height: 250px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px 230px;
  gap: 14px;
  padding: 16px;
  overflow: hidden;
  position: relative;
  isolation: isolate;
}

.heroPanel::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent, rgba(63, 224, 208, 0.08), transparent),
    repeating-linear-gradient(90deg, transparent 0 44px, rgba(255, 255, 255, 0.035) 44px 45px);
  content: "";
  animation: scanGlow 8s linear infinite;
}

.heroPanel::before {
  position: absolute;
  inset: 10px;
  z-index: 0;
  pointer-events: none;
  border: 1px solid rgba(63, 224, 208, 0.14);
  background:
    linear-gradient(115deg, rgba(101, 167, 255, 0.12), transparent 28%),
    repeating-linear-gradient(115deg, transparent 0 28px, rgba(63, 224, 208, 0.055) 28px 29px);
  clip-path: polygon(0 0, 96% 0, 100% 18%, 100% 100%, 5% 100%, 0 82%);
  content: "";
}

.heroCopy,
.signalPanel,
.telemetryStack {
  position: relative;
  z-index: 1;
}

.heroCopy {
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 16px;
}

.eyebrow,
.metricLabel,
.signalLabel {
  color: var(--teal);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 980px;
  font-size: 62px;
  line-height: 1.02;
  font-weight: 950;
}

h2 {
  font-size: 24px;
  line-height: 1.05;
  font-weight: 950;
}

.heroCopy p {
  max-width: 780px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.signalPanel {
  display: grid;
  align-content: center;
  gap: 9px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(63, 224, 208, 0.14), rgba(243, 201, 105, 0.065)),
    rgba(255, 255, 255, 0.04);
}

.signalPanel strong {
  color: var(--gold);
  font-size: 32px;
  font-weight: 950;
}

.signalPanel span:last-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.telemetryStack {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
  border: 1px solid rgba(202, 236, 241, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(101, 167, 255, 0.12), rgba(173, 140, 255, 0.07)),
    rgba(255, 255, 255, 0.035);
}

.telemetryStack span {
  color: var(--blue);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.telemetryStack strong {
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  font-weight: 950;
}

.telemetryStack small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metricStrip {
  display: grid;
  grid-template-columns: 1.1fr 0.55fr 0.55fr 1.05fr;
  gap: 10px;
  padding: 10px;
  background: rgba(9, 11, 13, 0.72);
}

.metricTile {
  min-height: 142px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(63, 224, 208, 0.07), transparent 42%),
    var(--surface-2);
}

.metricTile small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.metricValue {
  display: block;
  color: #f5fbfb;
  font-size: 44px;
  line-height: 1;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.pnlTile .metricValue {
  font-size: 50px;
}

.metricValue.positive,
.winText {
  color: var(--green);
  text-shadow: 0 0 18px rgba(48, 242, 138, 0.28);
}

.metricValue.negative,
.lossText {
  color: var(--red);
  text-shadow: 0 0 18px rgba(255, 70, 94, 0.25);
}

.equityTile {
  grid-template-columns: 160px minmax(0, 1fr);
  align-items: center;
}

#equityCanvas {
  min-height: 104px;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.panel {
  min-width: 0;
  padding: 14px;
}

.panelHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.chartStats {
  display: grid;
  gap: 4px;
  justify-items: end;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.chartStats strong {
  color: var(--gold);
  font-size: 15px;
  font-weight: 950;
}

.canvasFrame {
  height: 468px;
  border: 1px solid rgba(220, 232, 238, 0.12);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(3, 6, 8, 0.9), rgba(8, 10, 12, 0.96)),
    repeating-linear-gradient(0deg, transparent 0 36px, rgba(255, 255, 255, 0.035) 36px 37px);
  box-shadow:
    inset 0 0 0 1px rgba(63, 224, 208, 0.06),
    inset 0 0 80px rgba(63, 224, 208, 0.08),
    0 20px 80px rgba(0, 0, 0, 0.32);
}

.positionList {
  display: grid;
  gap: 8px;
  max-height: 468px;
  overflow: auto;
  padding-right: 2px;
}

.positionCard,
.emptyState {
  border: 1px solid rgba(220, 232, 238, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 12px;
}

.positionTop {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
  font-weight: 950;
}

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

.positionGrid div {
  display: grid;
  gap: 3px;
}

.positionGrid span,
.emptyState {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.positionGrid strong {
  font-size: 14px;
  font-weight: 950;
}

.ledgerPanel {
  padding: 14px;
}

.ledgerTable {
  overflow: auto;
}

.ledgerRow {
  display: grid;
  grid-template-columns: minmax(108px, 1.05fr) 0.65fr 0.75fr repeat(3, 0.95fr) 0.8fr 0.7fr;
  gap: 8px;
  align-items: center;
  min-width: 1050px;
}

.ledgerHeader {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 10px;
  color: var(--muted);
  background: rgba(8, 10, 12, 0.95);
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

#tradeLedgerBody {
  display: grid;
  gap: 7px;
}

.tradeLine {
  position: relative;
  min-height: 54px;
  padding: 9px 10px;
  border: 1px solid rgba(220, 232, 238, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #e8eff0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 830;
  overflow: hidden;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.tradeLine:hover,
.tradeLine.active {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background:
    linear-gradient(90deg, rgba(63, 224, 208, 0.12), rgba(101, 167, 255, 0.05)),
    rgba(255, 255, 255, 0.04);
}

.tradeLine span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sideLong,
.resultWin {
  color: var(--green);
}

.sideShort,
.resultLoss {
  color: var(--red);
}

.statusOpen {
  color: var(--blue);
}

.statusClosed {
  color: var(--gold);
}

.pnlChip,
.resultChip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  padding: 5px 8px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  font-weight: 950;
}

.pnlChip.positive,
.resultChip.win {
  color: var(--green);
  background: var(--green-soft);
  box-shadow: inset 0 0 0 1px rgba(48, 242, 138, 0.26), 0 0 18px rgba(48, 242, 138, 0.13);
}

.pnlChip.negative,
.resultChip.loss {
  color: var(--red);
  background: var(--red-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 70, 94, 0.28), 0 0 18px rgba(255, 70, 94, 0.12);
}

.symbolDockPanel {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: rgba(8, 10, 12, 0.9);
}

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

.dockHead strong {
  color: var(--muted);
  font-size: 12px;
}

.symbolDock {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: 7px;
}

.symbolBtn {
  min-height: 42px;
  border: 1px solid rgba(220, 232, 238, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: #e9f3f4;
  cursor: pointer;
  font-size: 12px;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.symbolBtn:hover,
.symbolBtn.active {
  transform: translateY(-1px);
  border-color: rgba(63, 224, 208, 0.58);
  background: rgba(63, 224, 208, 0.12);
  color: #ffffff;
}

.symbolBtn.hasOpen {
  box-shadow: inset 0 -2px 0 var(--gold);
}

.symbolBtn.hasWin {
  box-shadow: inset 0 -2px 0 var(--green);
}

.symbolBtn.hasLoss {
  box-shadow: inset 0 -2px 0 var(--red);
}

.metricPopWin {
  animation: metricWinPop 900ms cubic-bezier(0.18, 1.15, 0.22, 1);
}

.metricPopLoss {
  animation: metricLossPop 900ms cubic-bezier(0.18, 1.15, 0.22, 1);
}

.rowGlowWin {
  animation: rowWinGlow 1200ms ease-out;
}

.rowGlowLoss {
  animation: rowLossGlow 1200ms ease-out;
}

.lossShake {
  animation: lossShake 620ms ease-in-out;
}

.tradeEffect {
  position: fixed;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
  z-index: 9999;
}

.tradeEffect .particle {
  position: absolute;
  left: 0;
  top: 0;
  width: 7px;
  height: 3px;
  border-radius: 8px;
  opacity: 0;
  transform-origin: 0 50%;
}

.tradeEffect.win .particle {
  background: linear-gradient(90deg, #ffffff, var(--green), var(--gold));
  box-shadow: 0 0 12px rgba(48, 242, 138, 0.86);
  animation: fireworkParticle 900ms ease-out forwards;
}

.tradeEffect.loss .particle {
  width: 6px;
  height: 18px;
  background: linear-gradient(180deg, #ffffff, var(--red));
  box-shadow: 0 0 12px rgba(255, 70, 94, 0.86);
  animation: lossParticle 820ms ease-in forwards;
}

@keyframes scanGlow {
  0% { transform: translateX(-34%); opacity: 0.42; }
  50% { opacity: 0.82; }
  100% { transform: translateX(34%); opacity: 0.42; }
}

@keyframes metricWinPop {
  0% { transform: scale(1); filter: brightness(1); }
  20% { transform: scale(1.16); filter: brightness(1.8); text-shadow: 0 0 28px rgba(48, 242, 138, 0.68); }
  100% { transform: scale(1); filter: brightness(1); }
}

@keyframes metricLossPop {
  0% { transform: translateX(0) scale(1); filter: brightness(1); }
  16% { transform: translateX(-5px) scale(1.11); filter: brightness(1.7); text-shadow: 0 0 28px rgba(255, 70, 94, 0.68); }
  32% { transform: translateX(5px) scale(1.08); }
  48% { transform: translateX(-3px) scale(1.04); }
  100% { transform: translateX(0) scale(1); filter: brightness(1); }
}

@keyframes rowWinGlow {
  0% { border-color: rgba(48, 242, 138, 0.22); box-shadow: none; }
  25% { border-color: rgba(48, 242, 138, 0.9); box-shadow: 0 0 34px rgba(48, 242, 138, 0.28); }
  100% { border-color: rgba(220, 232, 238, 0.12); box-shadow: none; }
}

@keyframes rowLossGlow {
  0% { border-color: rgba(255, 70, 94, 0.22); box-shadow: none; }
  25% { border-color: rgba(255, 70, 94, 0.9); box-shadow: 0 0 34px rgba(255, 70, 94, 0.24); }
  100% { border-color: rgba(220, 232, 238, 0.12); box-shadow: none; }
}

@keyframes lossShake {
  0%, 100% { transform: translateX(0); }
  18% { transform: translateX(-8px); }
  36% { transform: translateX(7px); }
  54% { transform: translateX(-5px); }
  72% { transform: translateX(3px); }
}

@keyframes fireworkParticle {
  0% {
    opacity: 1;
    transform: rotate(var(--angle)) translateX(0) scale(0.8);
  }
  70% { opacity: 1; }
  100% {
    opacity: 0;
    transform: rotate(var(--angle)) translateX(var(--distance)) scale(0.2);
  }
}

@keyframes lossParticle {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(var(--angle)) scaleY(0.55);
  }
  100% {
    opacity: 0;
    transform: translate(var(--drift), var(--distance)) rotate(var(--angle)) scaleY(1.1);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 1180px) {
  .heroPanel,
  .metricStrip,
  .workbench {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 720px) {
  .siteShell {
    padding: 10px;
  }

  .topbar,
  .panelHead,
  .dockHead {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 36px;
  }

  h2 {
    font-size: 21px;
  }

  .metricValue,
  .pnlTile .metricValue {
    font-size: 36px;
  }

  .canvasFrame {
    height: 360px;
  }

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