:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #151b23;
  --panel-soft: #1b2430;
  --line: #2a3442;
  --text: #edf2f7;
  --muted: #94a3b8;
  --green: #1fc77e;
  --red: #ff5f70;
  --amber: #f7b955;
  --blue: #61a5ff;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(97, 165, 255, 0.08), transparent 330px),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 28px;
}

.topbar,
.quote-strip,
.workspace,
.newsline {
  display: grid;
  gap: 14px;
}

.topbar {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 18px;
}

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

.ticker-mark {
  display: grid;
  place-items: center;
  width: 82px;
  height: 54px;
  border: 1px solid rgba(97, 165, 255, 0.55);
  background: rgba(97, 165, 255, 0.12);
  color: #d9e9ff;
  font-weight: 800;
  border-radius: 8px;
  box-shadow: inset 0 0 28px rgba(97, 165, 255, 0.12);
}

.eyebrow,
.label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.14;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.market-clock {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.state-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.state-dot::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 18px var(--green);
}

.state-dot.muted::before {
  background: var(--muted);
  box-shadow: none;
}

.state-dot.closed::before {
  background: var(--amber);
  box-shadow: 0 0 18px rgba(247, 185, 85, 0.5);
}

.quote-strip {
  grid-template-columns: 1.4fr repeat(4, 1fr);
  margin-bottom: 14px;
}

.quote-strip article,
.chart-panel,
.tool-panel,
.newsline article {
  border: 1px solid var(--line);
  background: rgba(21, 27, 35, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.quote-strip article {
  min-height: 116px;
  padding: 18px;
}

.quote-strip strong {
  display: block;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.price-panel strong {
  font-size: 42px;
  line-height: 1;
}

.change {
  display: block;
  margin-top: 8px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

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

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

.workspace {
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: start;
}

.chart-panel,
.tool-panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

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

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 48px);
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  background: #10161e;
  border-radius: 8px;
}

.segmented button,
.icon-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
}

.segmented button {
  height: 32px;
}

.segmented button.active,
.segmented button:hover,
.icon-button:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  font-size: 20px;
}

.status-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #10161e;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
  font-size: 13px;
}

.status-link:hover {
  color: var(--text);
  border-color: var(--blue);
}

.backend-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #10161e;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

.backend-status strong {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.rule-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.rule-list li {
  position: relative;
  padding-left: 16px;
  color: #c7d2df;
  font-size: 13px;
  line-height: 1.45;
}

.rule-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1200 / 520;
  border: 1px solid var(--line);
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #10161e;
  background-size: 100% 25%, 12.5% 100%;
  border-radius: 8px;
}

.chart-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.side-rail {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.field input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  background: #10161e;
  color: var(--text);
  border-radius: 8px;
  padding: 0 12px;
  outline: none;
}

.field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(97, 165, 255, 0.16);
}

.hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.orderbook {
  display: grid;
  grid-template-columns: 46px 1fr 1fr;
  gap: 8px 10px;
  align-items: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

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

.orderbook strong,
.orderbook em {
  font-style: normal;
  text-align: right;
}

.orderbook strong:nth-of-type(-n + 5) {
  color: var(--red);
}

.newsline {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 14px;
}

.newsline article {
  padding: 16px 18px;
}

.newsline strong {
  display: block;
  min-height: 24px;
  font-size: 15px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(360px, calc(100vw - 36px));
  padding: 14px 16px;
  border: 1px solid rgba(247, 185, 85, 0.5);
  background: rgba(34, 25, 13, 0.96);
  color: #ffe7b5;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1050px) {
  .quote-strip,
  .workspace,
  .newsline {
    grid-template-columns: 1fr 1fr;
  }

  .price-panel,
  .chart-panel {
    grid-column: 1 / -1;
  }

  .side-rail {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 20px, 1480px);
    padding-top: 14px;
  }

  .topbar,
  .quote-strip,
  .workspace,
  .side-rail,
  .newsline {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: start;
  }

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

  .ticker-mark {
    width: 72px;
    height: 48px;
    font-size: 14px;
  }

  h1 {
    font-size: 22px;
  }

  .market-clock {
    justify-content: space-between;
  }

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

  .segmented {
    width: 100%;
    grid-template-columns: repeat(3, 1fr);
  }
}
