:root {
  --bg: #eef1ef;
  --surface: #ffffff;
  --surface-soft: #f6f8f7;
  --surface-strong: #e8eeeb;
  --text: #14201c;
  --muted: #66736d;
  --line: #d9e1dd;
  --line-strong: #bdc9c3;
  --green: #087a52;
  --green-soft: #e2f3eb;
  --red: #bc3f44;
  --red-soft: #f8e8e9;
  --blue: #285f84;
  --ink: #0e1713;
  --shadow: 0 10px 28px rgba(25, 45, 36, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), transparent 240px),
    var(--bg);
  color: var(--text);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.app-shell {
  width: min(1420px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 70px;
  border-bottom: 1px solid var(--line-strong);
  padding: 4px 2px 16px;
}

.brand-block h1,
.section-head h2,
.result-section-head h3 {
  margin: 0;
}

.brand-block h1 {
  font-size: clamp(24px, 2.3vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.brand-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.topbar-actions,
.section-head,
.header-tools,
.auto-run-toggle,
.interval-control,
.ghost-btn,
.sim-user-top,
.sim-user-meta,
.result-section-head,
.holdings-summary,
.trade-security,
.trade-price {
  display: flex;
  align-items: center;
}

.topbar-actions {
  gap: 8px;
}

.status-toast {
  min-width: 120px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.icon-button,
.ghost-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.icon-button:hover,
.ghost-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
  transform: translateY(-1px);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

.icon-button svg,
.ghost-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.dashboard {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  padding-top: 14px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sim-panel {
  position: sticky;
  top: 14px;
  padding: 16px;
}

.workspace-panel {
  padding: 18px;
}

.section-head {
  justify-content: space-between;
  gap: 18px;
}

.section-head h2 {
  font-size: 19px;
  letter-spacing: -0.02em;
}

.compact-head {
  margin-bottom: 13px;
}

.workspace-head {
  padding-bottom: 16px;
}

.header-tools {
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.ghost-btn {
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border-radius: 9px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 800;
}

.ghost-btn.primary-action {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.ghost-btn.primary-action:hover {
  background: #22312a;
}

.auto-run-toggle,
.interval-control {
  gap: 7px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
}

.auto-run-toggle input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--green);
}

.interval-control select {
  width: auto;
  min-width: 84px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  font-weight: 800;
}

.sim-user-list {
  display: grid;
  gap: 8px;
}

.sim-user {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 12px;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.sim-user:hover {
  border-color: var(--line-strong);
  transform: translateX(2px);
}

.sim-user.active {
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: inset 3px 0 0 var(--ink);
}

.sim-user-top,
.sim-user-meta {
  justify-content: space-between;
  gap: 8px;
}

.sim-user-top strong {
  font-size: 14px;
}

.sim-user-top span,
.sim-user-meta span,
.sim-user-latest {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.sim-user-money {
  font-family: "DIN Alternate", "Avenir Next", sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sim-user-latest {
  overflow: hidden;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.metric {
  position: relative;
  min-width: 0;
  padding: 15px 17px;
}

.metric + .metric {
  border-left: 1px solid var(--line);
}

.metric span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.metric strong {
  display: block;
  overflow: hidden;
  font-family: "DIN Alternate", "Avenir Next", sans-serif;
  font-size: clamp(21px, 2vw, 29px);
  line-height: 1;
  letter-spacing: -0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-strip {
  display: flex;
  align-items: center;
  gap: 7px 16px;
  flex-wrap: wrap;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.market-strip span {
  position: relative;
}

.market-strip span + span::before {
  position: absolute;
  top: 50%;
  left: -9px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line-strong);
  content: "";
  transform: translateY(-50%);
}

.result-section {
  margin-top: 18px;
  border-top: 1px solid var(--line-strong);
  padding-top: 17px;
}

.result-section-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 11px;
}

.result-section-head h3 {
  font-size: 17px;
  letter-spacing: -0.02em;
}

.result-section-head > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.holdings-summary {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.holdings-summary strong {
  margin-left: 5px;
  color: var(--text);
  font-family: "DIN Alternate", "Avenir Next", sans-serif;
  font-size: 14px;
}

.pnl-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 13px;
  text-align: left;
  white-space: nowrap;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  font-family: "DIN Alternate", "Avenir Next", sans-serif;
  font-size: 13px;
}

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

tbody tr:hover td {
  background: #fbfcfb;
}

.pnl-table td:first-child {
  font-family: "Avenir Next", "PingFang SC", sans-serif;
  font-weight: 800;
}

.pnl-table td small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-family: "DIN Alternate", sans-serif;
  font-size: 10px;
  font-weight: 700;
}

.trade-list {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}

.trade-row {
  display: grid;
  grid-template-columns: 72px minmax(135px, 1.1fr) minmax(90px, 0.7fr) minmax(78px, 0.6fr) minmax(100px, 0.75fr) minmax(118px, 0.85fr) 82px 170px;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px 14px;
}

.trade-row + .trade-row {
  border-top: 1px solid var(--line);
}

.trade-row:hover {
  background: #fbfcfb;
}

.trade-side {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  min-height: 27px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 900;
}

.trade-side.buy {
  background: var(--green-soft);
  color: var(--green);
}

.trade-side.sell {
  background: var(--red-soft);
  color: var(--red);
}

.trade-security {
  min-width: 0;
  gap: 9px;
}

.trade-security strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trade-security small {
  color: var(--muted);
  font-family: "DIN Alternate", sans-serif;
  font-size: 10px;
  font-weight: 700;
}

.trade-cell {
  min-width: 0;
}

.trade-cell span,
.trade-pnl span,
.trade-score span,
.trade-time span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.trade-cell strong,
.trade-pnl strong,
.trade-score strong,
.trade-time time {
  font-family: "DIN Alternate", "Avenir Next", sans-serif;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.trade-pnl small {
  display: block;
  margin-top: 2px;
  font-family: "DIN Alternate", "Avenir Next", sans-serif;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.trade-score strong {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 27px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface-soft);
}

.trade-time {
  justify-self: end;
  text-align: right;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  padding: 18px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.trade-list > .empty {
  margin: 12px;
}

.up {
  color: var(--green) !important;
}

.down {
  color: var(--red) !important;
}

.flat {
  color: var(--text) !important;
}

@media (max-width: 1280px) {
  .trade-row {
    grid-template-columns: 90px minmax(130px, 1fr) minmax(118px, 0.85fr) 82px;
  }

  .trade-side {
    grid-column: 1;
    grid-row: 1;
  }

  .trade-security {
    grid-column: 2;
    grid-row: 1;
  }

  .trade-pnl {
    grid-column: 3;
    grid-row: 1;
  }

  .trade-score {
    grid-column: 4;
    grid-row: 1;
    justify-self: end;
  }

  .trade-price {
    grid-column: 1;
    grid-row: 2;
  }

  .trade-quantity {
    grid-column: 2;
    grid-row: 2;
  }

  .trade-amount {
    grid-column: 3 / -1;
    grid-row: 2;
  }

  .trade-time {
    grid-column: 2 / -1;
    grid-row: 3;
    justify-self: start;
    text-align: left;
  }
}

@media (max-width: 920px) {
  .app-shell {
    width: min(100% - 22px, 760px);
  }

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

  .sim-panel {
    position: static;
  }

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

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

  .header-tools {
    justify-content: flex-start;
  }

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

  .metric:nth-child(3) {
    border-left: 0;
  }

  .metric:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 16px, 560px);
    padding-top: 10px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand-note,
  .status-toast {
    display: none;
  }

  .workspace-panel,
  .sim-panel {
    padding: 13px;
  }

  .sim-user-list {
    grid-template-columns: 1fr;
  }

  .header-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .ghost-btn,
  .auto-run-toggle,
  .interval-control {
    width: 100%;
  }

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

  .result-section-head > span {
    max-width: 140px;
    text-align: right;
  }

  .trade-list {
    gap: 9px;
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .trade-row {
    grid-template-columns: 64px minmax(0, 1fr) 72px;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    padding: 12px;
  }

  .trade-row + .trade-row {
    border-top: 1px solid var(--line);
  }

  .trade-price,
  .trade-quantity,
  .trade-amount {
    grid-column: auto;
  }

  .trade-side {
    grid-column: 1;
    grid-row: 1;
  }

  .trade-security {
    grid-column: 2;
    grid-row: 1;
  }

  .trade-price {
    grid-column: 1;
    grid-row: 2;
  }

  .trade-quantity {
    grid-column: 2;
    grid-row: 2;
  }

  .trade-amount {
    grid-column: 3;
    grid-row: 2;
  }

  .trade-pnl {
    display: flex;
    grid-column: 1 / -1;
    grid-row: 3;
    align-items: baseline;
    gap: 8px;
    border-top: 1px solid var(--line);
    padding-top: 8px;
  }

  .trade-pnl span,
  .trade-pnl small {
    margin: 0;
  }

  .trade-score {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }

  .trade-time {
    grid-column: 1 / -1;
    grid-row: 4;
    justify-self: start;
    border-top: 1px solid var(--line);
    padding-top: 8px;
    text-align: left;
  }
}

@media (max-width: 430px) {
  .topbar-actions .icon-button:first-of-type {
    display: none;
  }

  .metric {
    padding: 13px;
  }

  .metric strong {
    font-size: 21px;
  }

  .trade-row {
    grid-template-columns: 58px minmax(0, 1fr) 62px;
  }

  .trade-cell strong,
  .trade-time time {
    font-size: 12px;
  }
}
