:root {
  --bg: #121212;
  --bg-soft: #181a1f;
  --panel: #17191f;
  --panel-soft: #1d2027;
  --line: #2b2f36;
  --line-soft: #22262d;
  --text: #f5f5f5;
  --muted: #9b9ea5;
  --accent: #f0b90b;
  --buy: #00c087;
  --sell: #ff5b6e;
  --danger: #ff7b72;
  --warn: #ffb86c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.hero {
  margin-bottom: 28px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.title {
  margin: 10px 0 8px;
  font-size: 40px;
  line-height: 1.1;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 760px;
  line-height: 1.6;
}

.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 24px 0;
}

.chip {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(16, 35, 48, 0.75);
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(24, 26, 31, 0.98), rgba(19, 21, 26, 0.98));
  padding: 18px;
  min-height: 180px;
}

.card h3,
.panel h3 {
  margin: 0 0 8px;
  font-size: 20px;
}

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

.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 192, 135, 0.14);
  color: var(--buy);
  font-size: 12px;
}

.status.warn {
  background: rgba(255, 184, 108, 0.14);
  color: var(--warn);
}

.status.danger {
  background: rgba(255, 91, 110, 0.14);
  color: var(--sell);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
}

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

.trade-table-wrap {
  overflow: auto;
}

.trade-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

.trade-table th {
  color: var(--muted);
  font-weight: 600;
  background: #16181d;
  position: sticky;
  top: 0;
}

.trade-buy {
  color: var(--buy);
}

.trade-sell {
  color: var(--sell);
}

.exchange-page {
  min-height: 100vh;
}

.exchange-topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: #0f1013;
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #f5f5f5;
  color: #121212;
  font-weight: 700;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 12px;
}

.global-nav {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
}

.global-nav a:hover {
  color: var(--text);
}

.instrument-strip {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: #15171c;
}

.instrument-main,
.instrument-stat {
  min-height: 72px;
  padding: 12px 18px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.instrument-code {
  font-size: 22px;
  font-weight: 700;
}

.instrument-source,
.instrument-label {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.instrument-stat strong {
  margin-top: 8px;
  font-size: 18px;
}

.trade-layout {
  display: grid;
  grid-template-columns: minmax(0, 4fr) minmax(280px, 1fr);
  gap: 0;
  height: calc(100vh - 128px);
  min-height: 700px;
  max-height: calc(100vh - 128px);
}

.center-stage,
.right-rail {
  border-right: 1px solid var(--line);
  min-height: 0;
}

.center-stage {
  border-radius: 0;
}

.right-rail {
  padding: 14px;
  background: var(--panel-soft);
}

.center-stage {
  padding: 0;
  overflow: hidden;
}

.chart-toolbar {
  min-height: 68px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: #14161b;
}

.toolbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.toolbar-subtitle {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.timeframe-bar {
  display: flex;
  gap: 8px;
}

.timeframe-button {
  min-width: 52px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #181b22;
  color: var(--muted);
  cursor: pointer;
}

.timeframe-button.is-active {
  color: #111;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

.chart-frame {
  padding: 10px;
  height: calc(100% - 68px);
  background: #111318;
  display: grid;
  grid-template-rows: 4fr 1fr;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

.tv-chart {
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

.price-chart {
  height: 100%;
  border: 1px solid var(--line);
}

.volume-chart {
  height: 100%;
  border: 1px solid var(--line);
}

.orderbook-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.orderbook-title {
  font-size: 18px;
  font-weight: 700;
}

.orderbook-precision {
  color: var(--muted);
  font-size: 12px;
}

.orderbook-head {
  margin-top: 6px;
  padding: 8px 4px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.orderbook-list {
  display: grid;
  gap: 2px;
}

.orderbook-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 4px 6px;
  font-size: 11px;
  overflow: hidden;
}

.orderbook-depth-bar {
  position: absolute;
  inset: 0 0 0 auto;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

.orderbook-row.ask .orderbook-depth-bar {
  background: linear-gradient(270deg, rgba(255, 91, 110, 0.4), transparent);
}

.orderbook-row.bid .orderbook-depth-bar {
  left: 0;
  right: auto;
  background: linear-gradient(90deg, rgba(0, 192, 135, 0.4), transparent);
}

.orderbook-row::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.22;
  pointer-events: none;
}

.orderbook-row.ask::before {
  background: linear-gradient(270deg, rgba(255, 91, 110, 0.28), transparent);
}

.orderbook-row.bid::before {
  background: linear-gradient(90deg, rgba(0, 192, 135, 0.28), transparent);
}

.orderbook-price.ask {
  color: var(--sell);
}

.orderbook-price.bid {
  color: var(--buy);
}

.orderbook-cell {
  position: relative;
  z-index: 1;
}

.orderbook-mid {
  margin: 10px 0;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #13161b;
}

.orderbook-mid-price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.orderbook-mid-price span {
  font-size: 24px;
  font-weight: 700;
}

.orderbook-mid-price small {
  color: var(--muted);
}

.depth-ratio {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.depth-ratio-buy,
.depth-ratio-sell {
  padding: 6px 8px;
  border-radius: 6px;
  text-align: center;
  font-size: 12px;
}

.depth-ratio-buy {
  background: rgba(0, 192, 135, 0.18);
  color: var(--buy);
}

.depth-ratio-sell {
  background: rgba(255, 91, 110, 0.18);
  color: var(--sell);
}

@media (max-width: 1320px) {
  .trade-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}

@media (max-width: 1100px) {
  .instrument-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trade-layout {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
  }

  .center-stage,
  .right-rail {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .exchange-topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
  }

  .instrument-strip {
    grid-template-columns: 1fr;
  }

  .timeframe-bar {
    flex-wrap: wrap;
  }

  .chart-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .tv-chart {
    height: 420px;
  }
}
