:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --panel: #121922;
  --panel-2: #17212d;
  --line: #253241;
  --text: #f4f7fb;
  --muted: #9aa9b8;
  --green: #29d391;
  --red: #ff6464;
  --amber: #f3b84b;
  --blue: #5aa7ff;
  --violet: #a18cff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(90, 167, 255, 0.15), transparent 32rem),
    linear-gradient(135deg, #0b0f14 0%, #111821 55%, #0e1319 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input {
  font: inherit;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(9, 13, 18, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--green), var(--blue));
  color: #07100d;
  font-weight: 900;
}

.brand span,
small,
.eyebrow {
  color: var(--muted);
}

nav {
  display: grid;
  gap: 8px;
}

nav a {
  color: var(--muted);
  padding: 11px 12px;
  border-radius: 8px;
  text-decoration: none;
}

nav a.active,
nav a:hover {
  color: var(--text);
  background: var(--panel-2);
}

.system-card {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 24px;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 8px rgba(41, 211, 145, 0.12);
}

main {
  margin-left: 260px;
  padding: 28px;
}

.topbar,
.panel-head,
.actions,
.metric-grid,
.workbench,
.portfolio-grid,
.profile-stats,
.stat-line,
.position,
.event,
.portfolio-row {
  display: flex;
}

.topbar,
.panel-head {
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 760px;
  font-size: 42px;
  line-height: 1.03;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
}

h3 {
  margin: 20px 0 10px;
  font-size: 14px;
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.actions {
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
}

.language-toggle {
  display: flex;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-right: 6px;
}

.language-toggle button {
  min-height: 38px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
}

.language-toggle button.active {
  background: var(--green);
  color: #06110d;
  font-weight: 900;
}

button,
select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}

button.primary {
  border-color: rgba(41, 211, 145, 0.45);
  background: var(--green);
  color: #06110d;
  font-weight: 800;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 28px 0 14px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.workbench.screen.active,
.portfolio-grid.screen.active {
  display: grid;
}

.screen > .metric-grid {
  margin-top: 28px;
}

.metric-grid article,
.dex-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 25, 34, 0.84);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}

.metric-grid article {
  padding: 18px;
}

.metric-grid span {
  color: var(--muted);
  font-size: 13px;
}

.metric-grid strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 30px;
}

.workbench {
  display: grid;
  grid-template-columns: 410px minmax(0, 1fr);
  gap: 14px;
}

.dex-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.dex-card {
  padding: 16px;
}

.dex-card strong,
.dex-card span {
  display: block;
}

.dex-card span {
  margin: 8px 0;
  color: var(--green);
  font-weight: 800;
}

.primary-dex {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.dex-status {
  flex: 0 0 auto;
  border: 1px solid rgba(41, 211, 145, 0.35);
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.wallet-loader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 16px;
}

.wallet-loader input {
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101720;
  color: var(--text);
  padding: 0 12px;
}

.panel {
  padding: 18px;
}

.screen:not(.active) {
  display: none !important;
}

.trader-list,
.positions,
.portfolio-rows,
.event-log {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.trader-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
}

.trader-card.active {
  border-color: var(--green);
  box-shadow: inset 3px 0 0 var(--green);
}

.card-top,
.wallet-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.card-actions,
.profile-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.profile-actions {
  justify-content: flex-end;
}

.dex-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(85, 166, 255, 0.45);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--blue);
  background: rgba(85, 166, 255, 0.08);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.dex-link:hover {
  border-color: var(--blue);
  background: rgba(85, 166, 255, 0.14);
}

.dex-link.compact {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.score {
  color: var(--green);
  font-weight: 900;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.mini-stats span,
.profile-stats span {
  color: var(--muted);
  font-size: 11px;
}

.mini-stats strong,
.profile-stats strong {
  display: block;
  margin-top: 3px;
}

.wallet-line {
  margin: 12px 0 14px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

canvas {
  width: 100%;
  height: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1218;
}

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

.profile-stats div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101720;
}

.position,
.event,
.portfolio-row,
.stat-line {
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.position,
.event,
.portfolio-row {
  padding: 12px;
  border-radius: 8px;
  background: #101720;
  border: 1px solid var(--line);
}

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

.short,
.danger {
  color: var(--red);
}

.portfolio-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 14px;
  margin-top: 14px;
}

.net-panel,
.defense-panel,
.how-panel {
  grid-column: 1 / -1;
}

.how-panel {
  margin-top: 14px;
}

.how-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.how-grid article {
  min-height: 150px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101720;
}

.how-grid strong {
  display: block;
  margin-bottom: 10px;
}

.how-grid p {
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 12px;
}

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

.control span {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

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

.portfolio-row input {
  width: 92px;
}

.exposure-bars {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: 64px 1fr 72px;
  align-items: center;
  gap: 12px;
}

.bar-shell {
  position: relative;
  height: 26px;
  border-radius: 8px;
  background: #0b1118;
  border: 1px solid var(--line);
  overflow: hidden;
}

.bar-zero {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

.bar-fill {
  position: absolute;
  top: 4px;
  bottom: 4px;
  border-radius: 6px;
}

.bar-fill.long-fill {
  left: 50%;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.bar-fill.short-fill {
  right: 50%;
  background: linear-gradient(90deg, var(--red), var(--amber));
}

.event strong {
  display: block;
}

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

@media (max-width: 1080px) {
  .sidebar {
    position: static;
    width: auto;
  }

  .system-card {
    position: static;
    margin-top: 18px;
  }

  main {
    margin-left: 0;
    padding: 18px;
  }

  .metric-grid,
  .dex-grid,
  .how-grid,
  .workbench,
  .portfolio-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  h1 {
    font-size: 31px;
  }

  .topbar,
  .panel-head,
  .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .profile-actions {
    justify-content: stretch;
  }

  .profile-actions .dex-link,
  .profile-actions button {
    width: 100%;
  }

  .metric-grid,
  .profile-stats,
  .mini-stats {
    grid-template-columns: 1fr 1fr;
  }
}
