:root {
  color-scheme: dark;
  --bg: #080b10;
  --panel: #0e131b;
  --panel-2: #111925;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #edf3f7;
  --muted: #7f8d99;
  --red: #f0445a;
  --green: #00a875;
  --cyan: #4bd8e7;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background:
    radial-gradient(circle at 15% -10%, rgba(46, 112, 128, 0.18), transparent 25%),
    linear-gradient(180deg, #090d13 0%, #07090d 100%);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
  margin: 0;
  min-height: 100vh;
}

.topbar {
  align-items: center;
  backdrop-filter: blur(18px);
  background: rgba(8, 11, 16, 0.86);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr auto;
  min-height: 58px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { align-items: center; display: flex; gap: 11px; }
.brandMark {
  background: var(--cyan);
  box-shadow: 0 0 18px rgba(75, 216, 231, 0.45);
  display: block;
  height: 25px;
  width: 4px;
}
.brand strong { display: block; font-size: 13px; letter-spacing: 0.16em; }
.brand small, .liveBox, .eyebrow { color: var(--muted); font-size: 9px; letter-spacing: 0.14em; }
.liveBox { align-items: center; display: flex; gap: 9px; justify-content: flex-end; }
.liveDot {
  animation: pulse 1.6s infinite;
  background: #32e2a0;
  border-radius: 50%;
  box-shadow: 0 0 10px #32e2a0;
  height: 6px;
  width: 6px;
}
@keyframes pulse { 50% { opacity: 0.35; } }

main {
  height: 100vh;
  margin: 0;
  max-width: none;
  padding: 18px 22px 32px;
  width: 100%;
}
.eyebrow { color: var(--cyan); font-weight: 700; margin: 0 0 8px; }
h2, p { margin-top: 0; }
h2 { font-size: 18px; letter-spacing: 0; margin-bottom: 0; }

.workspace { height: 100%; margin-top: 0; min-height: 0; }
.marketStack {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  height: 100%;
  min-width: 0;
}
#cn { order: 1; }
#us { order: 2; }
#crypto { order: 3; }
#other { order: 4; }
.marketSection {
  display: flex;
  flex-direction: column;
  min-height: 0;
  scroll-margin-top: 84px;
}
.sectionHead {
  align-items: end;
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}
.marketState {
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.12em;
  padding: 5px 8px;
}
.marketState.open { border-color: rgba(50, 226, 160, 0.36); color: #55e7ad; }
.marketState.closed { color: #75828c; }
.benchmarkLabel {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
  margin: 10px 0 6px;
}
.benchmarkGrid {
  display: grid;
  flex: 0 0 82px;
  gap: 5px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 0;
}
.heatGrid {
  display: grid;
  flex: 1 1 auto;
  gap: 5px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  min-height: 0;
}
.cryptoGrid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.otherGrid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.marketTile {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  padding: 9px;
  position: relative;
  text-align: left;
}
.marketTile.up {
  background: linear-gradient(145deg, rgba(240, 68, 90, calc(0.12 + var(--intensity))), rgba(240, 68, 90, 0.05));
  border-color: rgba(240, 68, 90, 0.2);
}
.marketTile.down {
  background: linear-gradient(145deg, rgba(0, 168, 117, calc(0.12 + var(--intensity))), rgba(0, 168, 117, 0.05));
  border-color: rgba(0, 168, 117, 0.2);
}
.marketTile.flat { background: var(--panel-2); }
.tileTop { align-items: start; display: flex; gap: 6px; justify-content: space-between; }
.tileTop span { font-size: 10px; font-weight: 800; letter-spacing: 0.08em; }
.tileTop small { color: rgba(255,255,255,.64); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tileTop .sectorName {
  color: rgba(255,255,255,.88);
  font-family: "Microsoft YaHei", sans-serif;
  font-weight: 650;
  letter-spacing: 0;
}
.tileChange {
  display: block;
  font-family: "Roboto Mono", Consolas, monospace;
  font-size: 17px;
  font-weight: 700;
  margin-top: auto;
}
.tilePrice { color: rgba(255,255,255,.64); display: block; font-family: "Roboto Mono", Consolas, monospace; font-size: 10px; margin-top: 4px; }
.benchmarkTile { min-height: 62px; }
.benchmarkTile .tileChange { font-size: 16px; margin-top: 8px; }
.benchmarkTile .tilePrice { bottom: 12px; position: absolute; right: 12px; }
.sourceStatus {
  align-items: center;
  bottom: 11px;
  color: rgba(127, 141, 153, 0.68);
  display: flex;
  font-family: "Roboto Mono", Consolas, monospace;
  font-size: 8px;
  gap: 7px;
  justify-content: flex-end;
  letter-spacing: 0.04em;
  max-width: calc(100vw - 44px);
  pointer-events: none;
  position: fixed;
  right: 22px;
  text-align: right;
  z-index: 5;
}
.sourceDot {
  background: #32e2a0;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(50, 226, 160, 0.7);
  flex: 0 0 auto;
  height: 5px;
  width: 5px;
}
.sourceStatus.degraded { color: rgba(240, 180, 68, 0.8); }
.sourceStatus.degraded .sourceDot { background: #f0b444; box-shadow: 0 0 8px rgba(240, 180, 68, 0.6); }
.sourceStatus.error { color: rgba(240, 68, 90, 0.82); }
.sourceStatus.error .sourceDot { background: var(--red); box-shadow: 0 0 8px rgba(240, 68, 90, 0.6); }

@media (max-width: 1180px) {
  main { height: auto; min-height: 100vh; overflow: visible; }
  .workspace, .marketStack { height: auto; }
  .marketStack { grid-template-columns: 1fr; }
  .marketStack { grid-template-rows: none; }
  .marketSection { min-height: auto; }
  .benchmarkGrid { flex-basis: auto; grid-auto-rows: 82px; }
  .heatGrid { flex: none; grid-auto-rows: 90px; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: none; }
  .cryptoGrid, .otherGrid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .sourceStatus {
    justify-content: flex-end;
    margin-top: 24px;
    max-width: none;
    position: static;
  }
}
@media (max-width: 820px) {
  .topbar { gap: 12px; grid-template-columns: 1fr auto; padding: 0 14px; }
  .liveBox { display: none; }
  main { padding: 17px 12px 28px; }
  .benchmarkGrid { grid-template-columns: 1fr 1fr; }
  .heatGrid, .cryptoGrid, .otherGrid { grid-auto-rows: 90px; grid-template-columns: 1fr 1fr; grid-template-rows: none; }
  .marketStack { gap: 42px; }
  .sourceStatus { margin-top: 24px; max-width: none; }
}

@media (min-width: 1600px) and (min-height: 850px) {
  h2 { font-size: 23px; }
  .benchmarkLabel { font-size: 12px; }
  .benchmarkGrid { flex-basis: 94px; }
  .benchmarkTile { min-height: 0; }
  .marketTile { padding: 12px 14px; }
  .tileTop span { font-size: 14px; }
  .tileTop .sectorName { font-size: 14px; }
  .tileTop small { font-size: 12px; }
  .tileChange { font-size: 27px; }
  .tilePrice { font-size: 12px; margin-top: 6px; }
  .benchmarkTile .tileChange { font-size: 24px; margin-top: auto; }
  .benchmarkTile .tilePrice { bottom: 14px; font-size: 12px; right: 14px; }
}

@media (min-width: 2800px) and (min-height: 1500px) {
  main { padding: 34px 42px 64px; }
  .marketStack { gap: 36px 38px; }
  .sectionHead { margin-bottom: 17px; }
  .eyebrow { font-size: 19px; margin-bottom: 14px; }
  h2 { font-size: 46px; }
  .marketState { font-size: 19px; padding: 12px 17px; }
  .benchmarkLabel { font-size: 23px; margin: 20px 0 12px; }
  .benchmarkGrid { flex-basis: 176px; gap: 10px; }
  .heatGrid { gap: 10px; }
  .marketTile { padding: 24px 26px; }
  .tileTop span, .tileTop .sectorName { font-size: 29px; }
  .tileTop small { font-size: 24px; }
  .tileChange { font-size: 64px; }
  .tilePrice { font-size: 25px; margin-top: 12px; }
  .benchmarkTile .tileChange { font-size: 52px; }
  .benchmarkTile .tilePrice { bottom: 26px; font-size: 24px; right: 26px; }
  .sourceStatus { bottom: 19px; font-size: 16px; gap: 13px; right: 42px; }
  .sourceDot { height: 9px; width: 9px; }
}
