:root {
  --paper: #f5f7f9;
  --ink: #141414;
  --muted: #68707a;
  --line: #d7dde3;
  --panel: #ffffff;
  --panel-2: #eef2f4;
  --green: #058f6e;
  --red: #d33f49;
  --blue: #276ef1;
  --yellow: #e4b51a;
  --black: #0b0d0f;
  --violet: #6157ff;
  --shadow: 0 18px 50px rgba(19, 28, 38, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 82% 8%, rgba(228, 181, 26, 0.18), transparent 26%),
    linear-gradient(90deg, rgba(20, 20, 20, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(20, 20, 20, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 26px 0 48px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.kicker {
  margin: 0 0 5px;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  font-family: "DIN Condensed", "Avenir Next Condensed", "PingFang SC", sans-serif;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(34px, 4vw, 64px);
  line-height: 0.95;
}

h2 {
  font-size: 25px;
}

.status-strip {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 6px;
}

.status-strip strong {
  color: var(--black);
}

.desk {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  align-items: stretch;
}

.controls {
  display: grid;
  grid-template-columns: 1.35fr 0.8fr 0.9fr 0.8fr auto;
  gap: 10px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 6px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.search-field {
  position: relative;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 0 11px;
  color: var(--black);
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 4px;
  outline: none;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

input:focus,
select:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(39, 110, 241, 0.12);
}

.suggestions {
  position: absolute;
  z-index: 10;
  top: calc(100% + 7px);
  left: 0;
  right: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 18px 42px rgba(15, 24, 34, 0.18);
}

.suggestions button {
  display: grid;
  grid-template-columns: 58px minmax(58px, 0.75fr) minmax(0, 1.35fr);
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  color: var(--ink);
  text-align: left;
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.suggestions button:last-child {
  border-bottom: 0;
}

.suggestions button:hover {
  background: #f1f4f7;
  box-shadow: none;
  transform: none;
}

.suggestions strong {
  font-weight: 900;
}

.suggestions span {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.suggestions small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button {
  min-height: 44px;
  padding: 0 16px;
  color: #fff;
  background: var(--black);
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

button:hover {
  background: #2d3338;
  transform: translateY(-1px);
}

.signal-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 6px;
}

.metric {
  min-height: 72px;
  padding: 12px;
  background: var(--panel);
}

.metric.wide {
  grid-column: span 2;
}

.metric span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  font-size: 23px;
  line-height: 1.1;
}

.matrix {
  margin-top: 14px;
  background: var(--black);
  border: 1px solid #20262b;
  box-shadow: var(--shadow);
  border-radius: 6px;
  overflow: hidden;
}

.canvas-wrap {
  height: clamp(260px, 34vw, 420px);
}

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

.legend {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #20262b;
}

.legend button {
  min-height: 34px;
  padding: 0 12px;
  color: #b8c1cc;
  background: #171b1f;
  border: 1px solid #2b333b;
}

.legend button.active {
  color: var(--black);
  background: var(--yellow);
  border-color: var(--yellow);
  box-shadow: 0 0 0 2px rgba(228, 181, 26, 0.18);
}

.results {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.stock-block {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 6px;
  overflow: hidden;
}

.stock-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #fff, #f7f9fb);
}

.stock-head h3 {
  margin: 0 0 4px;
  font-size: 24px;
}

.stock-head p {
  margin: 0;
  color: var(--muted);
}

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

.route-table th,
.route-table td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.route-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  color: var(--black);
  background: var(--panel-2);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 800;
}

.tag.contract {
  color: #fff;
  background: var(--red);
}

.tag.tokenized {
  color: #fff;
  background: var(--blue);
}

.tag.real_stock {
  color: #fff;
  background: var(--green);
}

.fee {
  font-weight: 900;
}

.note {
  max-width: 310px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

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

.actions a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  color: var(--black);
  text-decoration: none;
  background: var(--yellow);
  border-radius: 4px;
  font-weight: 800;
  font-size: 12px;
}

.actions a.secondary {
  color: #fff;
  background: var(--black);
}

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

  .topbar {
    display: grid;
  }

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

  .controls button {
    grid-column: span 2;
  }

  .route-table,
  .route-table tbody,
  .route-table tr,
  .route-table td {
    display: block;
    width: 100%;
  }

  .route-table thead {
    display: none;
  }

  .route-table tr {
    border-bottom: 1px solid var(--line);
  }

  .route-table td {
    border-bottom: 0;
    padding: 9px 14px;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100vw - 18px, 1440px);
    padding-top: 14px;
  }

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

  .controls button {
    grid-column: span 1;
  }

  .signal-panel {
    grid-template-columns: 1fr;
  }

  .metric.wide {
    grid-column: span 1;
  }

  .legend {
    overflow-x: auto;
  }

  .legend button {
    white-space: nowrap;
  }

  .suggestions button {
    grid-template-columns: 54px 76px minmax(0, 1fr);
  }
}
