:root {
  color-scheme: dark;
  --bg: #080b12;
  --bg-soft: #0f1420;
  --panel: rgba(17, 24, 39, 0.78);
  --panel-strong: rgba(21, 30, 46, 0.92);
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #eef2ff;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --accent: #60a5fa;
  --gold: #fbbf24;
  --red: #ef4444;
  --green: #22c55e;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% -10%, rgba(96, 165, 250, 0.24), transparent 28%),
    radial-gradient(circle at 86% 8%, rgba(239, 68, 68, 0.18), transparent 26%),
    linear-gradient(135deg, #070a10 0%, #0a1020 45%, #05070c 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(36px, 5vw, 68px);
  line-height: 0.96;
  letter-spacing: -0.06em;
}

h2 {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.subtitle {
  margin-top: 14px;
  color: var(--muted);
  font-size: 15px;
}

.market-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  min-width: 220px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.market-status strong,
.market-status span:last-child {
  display: block;
}

.market-status strong {
  font-size: 14px;
}

.market-status span:last-child {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 7px rgba(34, 197, 94, 0.12), 0 0 24px rgba(34, 197, 94, 0.8);
}

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

.summary-card,
.panel,
.control-card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.86), rgba(12, 18, 30, 0.74));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.summary-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border-radius: 22px;
}

.summary-card::after {
  content: "";
  position: absolute;
  inset: auto -30px -54px auto;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.09);
}

.summary-label {
  color: var(--muted);
  font-size: 12px;
}

.summary-value {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 8px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.summary-value small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
}

.summary-note {
  margin-top: 8px;
  color: var(--muted-2);
  font-size: 12px;
}

.control-card {
  display: grid;
  grid-template-columns: auto auto auto minmax(220px, 1fr);
  gap: 14px;
  align-items: end;
  padding: 16px;
  margin-bottom: 16px;
  border-radius: var(--radius-xl);
}

.control-group > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.segmented {
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.62);
}

.segmented button {
  border: 0;
  border-radius: 999px;
  padding: 9px 13px;
  color: var(--muted);
  background: transparent;
  transition: 0.18s ease;
  white-space: nowrap;
}

.segmented button:hover {
  color: var(--text);
  background: rgba(148, 163, 184, 0.08);
}

.segmented button.is-active {
  color: #e0f2fe;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.9), rgba(14, 165, 233, 0.72));
  box-shadow: 0 12px 30px rgba(14, 165, 233, 0.2);
}

.search-box input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 16px;
  color: var(--text);
  outline: none;
  background: rgba(15, 23, 42, 0.68);
}

.search-box input:focus {
  border-color: rgba(96, 165, 250, 0.62);
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.1);
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 340px;
  gap: 16px;
  min-height: 680px;
}

.panel {
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.heatmap-head {
  align-items: flex-end;
}

.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.legend-bar {
  width: 140px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #16a34a, #1f2937, #dc2626);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.rank-lists {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.rank-block {
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(2, 6, 23, 0.22);
}

.rank-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}

.rank-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  cursor: pointer;
  transition: 0.16s ease;
}

.rank-item:last-child {
  border-bottom: 0;
}

.rank-item:hover {
  background: rgba(96, 165, 250, 0.08);
}

.rank-no {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 8px;
  color: #bfdbfe;
  background: rgba(96, 165, 250, 0.14);
  font-size: 11px;
  font-weight: 800;
}

.rank-name {
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-meta {
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-value {
  font-size: 13px;
  font-weight: 800;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  grid-auto-rows: 54px;
  grid-auto-flow: dense;
  gap: 8px;
  padding: 18px;
  min-height: 620px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  min-height: 108px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 13px;
  color: #fff;
  isolation: isolate;
  transition: transform 0.16s ease, filter 0.16s ease, border-color 0.16s ease;
}

.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 0 0, rgba(255, 255, 255, 0.22), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.18));
}

.tile:hover,
.tile.is-selected {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.36);
  filter: brightness(1.08);
}

.tile.is-selected {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22), 0 18px 40px rgba(0, 0, 0, 0.28);
}

.tile-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.tile-name {
  font-size: clamp(13px, 1.1vw, 17px);
  font-weight: 900;
  letter-spacing: -0.03em;
}

.tile-badge {
  flex: none;
  padding: 3px 7px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.18);
  font-size: 10px;
  font-weight: 800;
}

.tile-change {
  margin-top: 6px;
  font-size: clamp(20px, 2vw, 34px);
  font-weight: 950;
  letter-spacing: -0.06em;
}

.tile-meta {
  display: grid;
  gap: 4px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
}

.tile-small .tile-meta span:nth-child(n + 3),
.tile-small .tile-badge {
  display: none;
}

.detail-panel {
  padding-bottom: 16px;
}

.empty-detail {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 100%;
  padding: 28px;
  text-align: center;
}

.empty-detail span {
  font-size: 18px;
  font-weight: 800;
}

.empty-detail p {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.7;
}

.detail-hero {
  padding: 22px;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(circle at 90% 10%, rgba(255, 255, 255, 0.12), transparent 28%),
    linear-gradient(135deg, rgba(37, 99, 235, 0.28), rgba(15, 23, 42, 0));
}

.detail-hero h2 {
  margin-top: 6px;
  font-size: 30px;
  letter-spacing: -0.05em;
}

.detail-change {
  margin-top: 12px;
  font-size: 42px;
  font-weight: 950;
  letter-spacing: -0.07em;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #dbeafe;
  background: rgba(96, 165, 250, 0.1);
  font-size: 12px;
  font-weight: 700;
}

.metric-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.metric {
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.22);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 16px;
}

.detail-section {
  padding: 0 16px 16px;
}

.detail-section h3 {
  margin: 4px 0 10px;
  font-size: 14px;
}

.etf-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.etf-pill {
  padding: 8px 10px;
  border-radius: 12px;
  color: #c7d2fe;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(129, 140, 248, 0.18);
  font-size: 12px;
  font-weight: 700;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #60a5fa, #f87171);
}

.tooltip {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transform: translate(10px, 10px);
  max-width: 280px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  color: var(--text);
  background: rgba(2, 6, 23, 0.92);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(16px);
  transition: opacity 0.12s ease;
}

.tooltip.is-visible {
  opacity: 1;
}

.tooltip h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.tooltip-grid {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.tooltip-grid div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.positive {
  color: #f87171;
}

.negative {
  color: #4ade80;
}

.neutral {
  color: #cbd5e1;
}

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

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

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

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

  .topbar,
  .workspace {
    grid-template-columns: 1fr;
    display: grid;
  }

  .summary-grid,
  .control-card {
    grid-template-columns: 1fr;
  }

  .segmented {
    overflow-x: auto;
  }

  .heatmap {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-rows: 58px;
  }
}
