:root {
  color-scheme: dark;
  --bg: #0b0d0c;
  --panel: #141715;
  --panel-2: #191d1a;
  --panel-3: #20251f;
  --line: #2b322d;
  --text: #edf4ef;
  --muted: #98a49d;
  --soft: #c6d0ca;
  --green: #56d89b;
  --green-soft: rgba(86, 216, 155, 0.16);
  --red: #ff6f7d;
  --red-soft: rgba(255, 111, 125, 0.15);
  --amber: #f4c15d;
  --amber-soft: rgba(244, 193, 93, 0.16);
  --blue: #7ab7ff;
  --purple: #bf8cff;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft JhengHei", "Noto Sans TC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(120deg, rgba(86, 216, 155, 0.08), transparent 34%),
    linear-gradient(240deg, rgba(244, 193, 93, 0.06), transparent 38%),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
}

.app-shell {
  width: min(1780px, 100%);
  min-height: 100vh;
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  gap: 18px;
  align-items: center;
  padding: 18px clamp(16px, 3vw, 34px);
  border-bottom: 1px solid rgba(198, 208, 202, 0.12);
  background: rgba(11, 13, 12, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px;
  border: 1px solid rgba(86, 216, 155, 0.38);
  border-radius: 8px;
  background: #101310;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.brand-mark span {
  align-self: end;
  border-radius: 3px;
  background: var(--green);
}

.brand-mark span:nth-child(1) {
  height: 42%;
}

.brand-mark span:nth-child(2) {
  height: 78%;
  background: var(--amber);
}

.brand-mark span:nth-child(3) {
  height: 58%;
  background: var(--blue);
}

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.18rem, 2.1vw, 1.78rem);
  line-height: 1.08;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.2;
}

h3 {
  margin-bottom: 12px;
  font-size: 1.02rem;
}

.status-strip {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.status-item {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid rgba(198, 208, 202, 0.14);
  border-radius: 8px;
  background: rgba(20, 23, 21, 0.78);
  color: var(--soft);
  font-size: 0.82rem;
  white-space: nowrap;
}

.status-item svg {
  width: 15px;
  height: 15px;
  color: var(--green);
}

.pulse {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(86, 216, 155, 0.5);
  animation: pulse 1.55s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(86, 216, 155, 0.5);
  }

  70% {
    box-shadow: 0 0 0 8px rgba(86, 216, 155, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(86, 216, 155, 0);
  }
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.icon-button,
.command-button,
.mini-button,
.segmented button {
  min-height: 38px;
  border: 1px solid rgba(198, 208, 202, 0.14);
  border-radius: 8px;
  background: var(--panel-2);
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.icon-button:hover,
.command-button:hover,
.mini-button:hover,
.segmented button:hover {
  border-color: rgba(86, 216, 155, 0.42);
  transform: translateY(-1px);
}

.icon-button {
  display: grid;
  width: 42px;
  place-items: center;
}

.icon-button svg,
.command-button svg,
.section-head > svg,
.search-box svg {
  width: 17px;
  height: 17px;
}

.icon-fallback {
  display: none;
}

.command-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  font-weight: 800;
}

.command-button.danger {
  border-color: rgba(255, 111, 125, 0.34);
  background: rgba(255, 111, 125, 0.12);
  color: #ffd7db;
}

.command-button.unlocked {
  border-color: rgba(86, 216, 155, 0.42);
  background: var(--green-soft);
  color: #d9ffee;
}

.workspace {
  padding: 20px clamp(16px, 3vw, 34px) 34px;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric-tile {
  min-height: 104px;
  padding: 18px;
  border: 1px solid rgba(198, 208, 202, 0.13);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent),
    var(--panel);
  box-shadow: var(--shadow);
}

.metric-tile p {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.metric-tile strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(1.36rem, 2.4vw, 2.1rem);
  line-height: 1.05;
}

.trend {
  display: inline-flex;
  margin-top: 12px;
  font-size: 0.8rem;
  font-weight: 800;
}

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

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

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

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(250px, 310px) minmax(520px, 1fr) minmax(280px, 360px);
  gap: 16px;
  align-items: start;
}

.trader-rail,
.main-board,
.tool-panel {
  border: 1px solid rgba(198, 208, 202, 0.13);
  border-radius: 8px;
  background: rgba(20, 23, 21, 0.88);
  box-shadow: var(--shadow);
}

.trader-rail,
.tool-panel {
  padding: 15px;
}

.main-board {
  min-width: 0;
  padding: 16px;
}

.right-rail {
  display: grid;
  gap: 16px;
}

.section-head {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-head.compact {
  margin-bottom: 12px;
}

.section-head > svg {
  flex: 0 0 auto;
  color: var(--amber);
}

.mini-button {
  padding: 0 11px;
  color: var(--soft);
  font-size: 0.8rem;
  font-weight: 800;
}

.search-box {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  padding: 0 11px;
  border: 1px solid rgba(198, 208, 202, 0.12);
  border-radius: 8px;
  background: #0f1210;
}

.search-box svg {
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.trader-list {
  display: grid;
  gap: 10px;
}

.trader-card {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 11px;
  min-height: 92px;
  padding: 11px;
  border: 1px solid rgba(198, 208, 202, 0.12);
  border-radius: 8px;
  background: #101310;
  text-align: left;
}

.trader-card:hover,
.trader-card.active {
  border-color: rgba(86, 216, 155, 0.58);
  background: #151b16;
}

.avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #07100b;
  font-size: 0.76rem;
  font-weight: 900;
}

.trader-main {
  min-width: 0;
}

.trader-line {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.trader-line strong {
  overflow: hidden;
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--green);
}

.status-dot.watch {
  background: var(--amber);
}

.trader-card p {
  margin: 2px 0 8px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trader-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  align-items: end;
}

.trader-stats span {
  color: var(--muted);
  font-size: 0.68rem;
}

.trader-stats b {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
  font-size: 0.78rem;
}

.sparkline {
  position: absolute;
  right: 10px;
  bottom: 9px;
  width: 86px;
  height: 20px;
  opacity: 0.58;
  pointer-events: none;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(54px, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(198, 208, 202, 0.12);
  border-radius: 8px;
  background: #0f1210;
}

.segmented button {
  min-height: 30px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.79rem;
  font-weight: 800;
}

.segmented button.active {
  background: var(--green-soft);
  color: var(--green);
}

.chart-band {
  display: grid;
  grid-template-columns: minmax(180px, 230px) minmax(0, 1fr);
  gap: 14px;
  min-height: 226px;
  margin-bottom: 14px;
  padding: 15px;
  border: 1px solid rgba(198, 208, 202, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(86, 216, 155, 0.1), transparent 42%),
    linear-gradient(315deg, rgba(122, 183, 255, 0.08), transparent 46%),
    #101310;
}

.chart-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: space-between;
}

.chart-copy dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.chart-copy dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.chart-copy dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 1rem;
  font-weight: 900;
}

#equityChart {
  display: block;
  width: 100%;
  min-width: 0;
  height: 195px;
}

.table-shell {
  overflow-x: auto;
  border: 1px solid rgba(198, 208, 202, 0.12);
  border-radius: 8px;
  background: #101310;
}

table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 11px;
  border-bottom: 1px solid rgba(198, 208, 202, 0.08);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

td {
  color: var(--soft);
  font-size: 0.82rem;
}

tr:last-child td {
  border-bottom: 0;
}

.pill {
  display: inline-flex;
  min-width: 58px;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
}

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

.pill.short {
  background: var(--red-soft);
  color: var(--red);
}

.ranking-list {
  display: grid;
  gap: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(82px, 1fr) 48px;
  gap: 10px;
  align-items: center;
}

.rank-row span {
  overflow: hidden;
  color: var(--soft);
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-row b {
  color: var(--green);
  font-size: 0.8rem;
  text-align: right;
}

.rank-bar {
  grid-column: 1 / -1;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(198, 208, 202, 0.1);
}

.rank-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--amber));
}

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

.risk-grid div {
  min-height: 74px;
  padding: 12px;
  border: 1px solid rgba(198, 208, 202, 0.1);
  border-radius: 8px;
  background: #101310;
}

.risk-grid span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.72rem;
}

.risk-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.events-panel {
  max-height: 410px;
  overflow: hidden;
}

.event-tape {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.event-tape li {
  display: grid;
  gap: 3px;
  padding-left: 13px;
  border-left: 2px solid rgba(86, 216, 155, 0.55);
}

.event-tape time {
  color: var(--muted);
  font-size: 0.68rem;
}

.event-tape span {
  color: var(--soft);
  font-size: 0.78rem;
  line-height: 1.35;
}

.muted-empty {
  padding: 24px 12px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1280px) {
  .dashboard-grid {
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  }

  .right-rail {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
  }

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

  .top-actions {
    justify-content: flex-start;
  }

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

  .dashboard-grid,
  .right-rail {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 680px) {
  .workspace {
    padding-inline: 12px;
  }

  .topbar {
    padding-inline: 12px;
  }

  .metrics-row,
  .trader-list {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }

  .chart-band {
    grid-template-columns: 1fr;
  }

  #equityChart {
    height: 180px;
  }
}
