:root {
  color-scheme: dark;
  --bg: #0c0f12;
  --panel: #151a20;
  --panel-strong: #1b222a;
  --line: #28313b;
  --line-soft: #202832;
  --text: #f4f6f8;
  --soft: #d9e0e7;
  --muted: #94a2b0;
  --green: #19c37d;
  --red: #ff5c72;
  --amber: #f0b84a;
  --cyan: #45d4d0;
  --blue: #58a6ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(69, 212, 208, 0.05), transparent 280px),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.app-shell {
  width: min(1540px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.top-bar,
.brand-block,
.top-actions,
.status-pill,
.button,
.panel-head,
.price-line,
.overview-metrics,
.chart-legend,
.book-row,
.trade-row,
.liquidation-row,
.disclaimer-panel {
  display: flex;
  align-items: center;
}

.top-bar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.brand-block {
  gap: 14px;
  min-width: 280px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(240, 184, 74, 0.38);
  border-radius: 8px;
  background: #241f14;
  color: var(--amber);
  font-size: 16px;
  font-weight: 950;
}

.eyebrow,
.metric-card span,
.timestamp,
.price-subline,
.trade-row span,
.book-row span,
.liquidation-row span,
.disclaimer-panel p,
.chart-legend,
.metric-card small {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 5px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(25px, 3vw, 40px);
  line-height: 1.08;
}

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

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

.status-pill {
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10151a;
  color: var(--soft);
  font-weight: 750;
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 18px rgba(240, 184, 74, 0.55);
}

.status-pill.online .status-dot {
  background: var(--green);
  box-shadow: 0 0 18px rgba(25, 195, 125, 0.55);
}

.status-pill.error .status-dot {
  background: var(--red);
  box-shadow: 0 0 18px rgba(255, 92, 114, 0.55);
}

.button {
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid #38434f;
  border-radius: 8px;
  padding: 0 13px;
  background: #202832;
  color: var(--text);
  cursor: pointer;
}

.button:hover {
  border-color: #576677;
}

.button svg,
.risk-icon svg {
  width: 18px;
  height: 18px;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

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

.overview-panel,
.chart-panel,
.factors-panel,
.metric-card,
.recorder-panel,
.disclaimer-panel {
  padding: 16px;
}

.overview-panel {
  grid-column: span 2;
  background:
    linear-gradient(145deg, rgba(25, 195, 125, 0.12), transparent 42%),
    var(--panel);
}

body[data-direction="down"] .overview-panel {
  background:
    linear-gradient(145deg, rgba(255, 92, 114, 0.13), transparent 42%),
    var(--panel);
}

body[data-direction="neutral"] .overview-panel {
  background:
    linear-gradient(145deg, rgba(240, 184, 74, 0.12), transparent 42%),
    var(--panel);
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.timestamp,
.mini-value {
  color: var(--soft);
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.price-line {
  justify-content: space-between;
  gap: 16px;
}

.last-price {
  font-size: clamp(42px, 6vw, 72px);
  font-weight: 950;
  line-height: 0.98;
}

.price-subline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  font-weight: 800;
}

.direction-badge {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border: 1px solid rgba(240, 184, 74, 0.34);
  border-radius: 999px;
  background: rgba(240, 184, 74, 0.1);
  color: var(--amber);
  font-size: 22px;
  font-weight: 950;
}

body[data-direction="up"] .direction-badge {
  border-color: rgba(25, 195, 125, 0.4);
  background: rgba(25, 195, 125, 0.11);
  color: var(--green);
}

body[data-direction="down"] .direction-badge {
  border-color: rgba(255, 92, 114, 0.42);
  background: rgba(255, 92, 114, 0.11);
  color: var(--red);
}

.overview-metrics {
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.overview-metrics div {
  display: grid;
  gap: 5px;
}

.overview-metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.overview-metrics strong {
  font-size: 18px;
}

.metric-card {
  display: grid;
  align-content: space-between;
  min-height: 150px;
  gap: 10px;
}

.metric-card span,
.metric-card small {
  font-size: 13px;
  font-weight: 800;
}

.metric-card strong {
  color: var(--soft);
  font-size: clamp(20px, 2.4vw, 28px);
  line-height: 1.12;
}

.recorder-panel {
  grid-column: 1 / -1;
}

.recorder-head {
  margin-bottom: 12px;
}

.recorder-grid {
  display: grid;
  grid-template-columns: 1.1fr repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.recorder-grid div {
  display: grid;
  gap: 4px;
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #10151a;
}

.recorder-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.recorder-grid strong {
  color: var(--soft);
  font-size: 20px;
  line-height: 1.2;
}

.recorder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.danger-button {
  border-color: rgba(255, 92, 114, 0.45);
  color: #ffd6dc;
}

.danger-button:hover {
  border-color: rgba(255, 92, 114, 0.78);
}

.chart-panel.wide {
  grid-column: span 2;
}

.chart-frame {
  position: relative;
  height: 250px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #0e1216;
}

.chart-frame.tall {
  height: 380px;
}

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

.chart-legend {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  font-weight: 800;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 999px;
}

.green {
  background: var(--green);
}

.red {
  background: var(--red);
}

.cyan {
  background: var(--cyan);
}

.book-ladder,
.trade-tape,
.liquidation-tape {
  display: grid;
  gap: 5px;
  margin-top: 12px;
}

.book-row,
.trade-row,
.liquidation-row {
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 12px;
  font-weight: 800;
}

.book-row strong,
.trade-row strong,
.liquidation-row strong {
  color: var(--soft);
}

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

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

.factor-list {
  display: grid;
  gap: 12px;
}

.factor-row {
  display: grid;
  grid-template-columns: 110px 1fr 58px;
  align-items: center;
  gap: 10px;
}

.factor-name {
  color: var(--soft);
  font-size: 13px;
  font-weight: 850;
}

.factor-bar {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #303944;
}

.factor-bar::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: rgba(255, 255, 255, 0.36);
  content: "";
}

.factor-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  background: var(--green);
}

.factor-fill.negative {
  right: 50%;
  left: auto;
  background: var(--red);
}

.factor-score {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  text-align: right;
}

.disclaimer-panel {
  grid-column: 1 / -1;
  align-items: flex-start;
  gap: 14px;
  background: #171511;
  border-color: rgba(240, 184, 74, 0.28);
}

.disclaimer-panel h2 {
  margin-bottom: 4px;
  font-size: 17px;
}

.disclaimer-panel p {
  margin-bottom: 0;
  color: #e2d5b8;
  line-height: 1.55;
}

.risk-icon {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(240, 184, 74, 0.13);
  color: var(--amber);
}

@media (max-width: 1180px) {
  .top-bar {
    align-items: flex-start;
    flex-direction: column;
  }

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

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

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

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

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

  .overview-panel,
  .chart-panel.wide,
  .disclaimer-panel {
    grid-column: auto;
  }

  .price-line,
  .overview-metrics {
    align-items: stretch;
    flex-direction: column;
  }

  .direction-badge {
    width: 100%;
    height: 54px;
    border-radius: 8px;
  }

  .metric-card {
    min-height: 118px;
  }

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

  .recorder-actions .button {
    flex: 1 1 150px;
  }

  .chart-frame,
  .chart-frame.tall {
    height: 270px;
  }

  .factor-row {
    grid-template-columns: 92px 1fr 48px;
  }
}
