:root {
  color-scheme: dark;
  --bg: #101114;
  --surface: #17191e;
  --surface-2: #20242a;
  --line: #31363f;
  --text: #eef2f0;
  --muted: #9aa5a3;
  --green: #26c281;
  --red: #ff5b68;
  --amber: #f6b84b;
  --cyan: #62c6d9;
  --blue: #7ca7ff;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(40, 46, 52, 0.92), rgba(16, 17, 20, 0.96) 340px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar,
.controls,
.section-head,
.metric-grid,
.hero-grid,
.board-grid {
  display: grid;
  gap: 16px;
}

.topbar {
  grid-template-columns: 1fr auto;
  align-items: end;
  padding-bottom: 16px;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 52px);
  line-height: 1.02;
}

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

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

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
  align-items: center;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
}

.status-ok {
  color: var(--green);
  border-color: rgba(38, 194, 129, 0.35);
}

.status-warn {
  color: var(--amber);
  border-color: rgba(246, 184, 75, 0.4);
}

.status-bad {
  color: var(--red);
  border-color: rgba(255, 91, 104, 0.42);
}

.controls {
  grid-template-columns: minmax(190px, 260px) minmax(180px, 240px) minmax(180px, 280px) auto;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 25, 30, 0.86);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #111318;
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(98, 198, 217, 0.14);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  min-height: 40px;
  border: 0;
  color: var(--text);
  background: #15181d;
}

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

.segmented button:hover,
.segmented button[aria-pressed="true"] {
  background: var(--surface-2);
}

.metric-grid {
  grid-template-columns: repeat(4, 1fr);
  margin-top: 16px;
}

.notice {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(246, 184, 75, 0.4);
  border-radius: 8px;
  color: #f6d28a;
  background: rgba(246, 184, 75, 0.1);
}

.metric-grid article,
.panel,
.market-map,
.watch-strip,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 25, 30, 0.92);
  box-shadow: var(--shadow);
}

.metric-grid article {
  display: grid;
  gap: 8px;
  min-height: 116px;
  padding: 16px;
}

.metric-grid span {
  color: var(--muted);
  font-size: 13px;
}

.metric-grid strong {
  font-size: 28px;
}

.hero-grid {
  grid-template-columns: minmax(0, 1fr) 330px;
  margin-top: 16px;
}

.market-map,
.watch-strip,
.table-panel,
.panel {
  padding: 16px;
}

.section-head {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 14px;
}

.section-head.compact {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  margin-bottom: 12px;
}

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

#heatCanvas {
  display: block;
  width: 100%;
  height: 260px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  background: #0f1116;
}

.major-list,
.rank-list,
.tape {
  display: grid;
  gap: 8px;
}

.major {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #12151a;
}

.major strong,
.row-symbol {
  font-weight: 900;
}

.major .price {
  text-align: right;
}

.spark {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--red), var(--amber), var(--green));
  transform-origin: left center;
}

.board-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 16px;
}

.rank-row,
.tape-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  background: #12151a;
}

.rank-row .rank {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: #c8d1cf;
  background: var(--surface-2);
  font-weight: 900;
  font-size: 12px;
}

.rank-row small,
.tape-row small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.change,
.money {
  font-weight: 900;
  text-align: right;
}

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

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

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

.table-panel {
  margin-top: 16px;
}

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

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
}

tbody tr:hover {
  background: rgba(98, 198, 217, 0.07);
}

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

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

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

  .watch-strip {
    min-height: 0;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1480px);
    padding-top: 16px;
  }

  .topbar,
  .controls,
  .metric-grid,
  .board-grid,
  .section-head {
    grid-template-columns: 1fr;
  }

  .status-cluster {
    justify-content: start;
  }

  .metric-grid article {
    min-height: 96px;
  }

  h1 {
    font-size: 34px;
  }
}
