:root {
  --bg-primary: #0a0a0f;
  --bg-card: #12121a;
  --bg-card-hover: #1a1a26;
  --border: #1e1e2e;
  --text-primary: #e8e8ed;
  --text-secondary: #8888a0;
  --text-dim: #55556a;
  --green: #00dc82;
  --green-dim: rgba(0,220,130,0.12);
  --red: #ff4757;
  --red-dim: rgba(255,71,87,0.12);
  --amber: #ffa502;
  --amber-dim: rgba(255,165,2,0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59,130,246,0.12);
  --purple: #a855f7;
  --cyan: #22d3ee;
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

.dashboard {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.live-dot {
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(0,220,130,0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(0,220,130,0); }
}

.timestamp {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-secondary);
}

.data-mode-toggle {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.data-mode-toggle button {
  padding: 6px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.data-mode-toggle button.active {
  background: var(--blue-dim);
  color: var(--blue);
}

/* ===== GRID ===== */
.grid-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.grid-bottom {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* ===== CARD ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.5s ease forwards;
}

.card:hover {
  border-color: rgba(255,255,255,0.06);
  background: var(--bg-card-hover);
}

.grid-top .card:nth-child(2) { animation-delay: 0.1s; }
.grid-bottom .card:nth-child(1) { animation-delay: 0.2s; }
.grid-bottom .card:nth-child(2) { animation-delay: 0.3s; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
}

.card-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 6px;
  font-weight: 500;
}

/* ===== NASDAQ ===== */
.nasdaq-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 8px;
}

.nasdaq-sub {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
}

.nasdaq-sub-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nasdaq-sub-label {
  font-size: 11px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nasdaq-sub-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 500;
}

.valuation-bar-container { margin-top: 16px; }

.valuation-bar-labels {
  display: flex;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.valuation-bar {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--green), var(--amber), var(--red));
  position: relative;
}

.valuation-marker {
  position: absolute;
  top: -6px;
  width: 3px;
  height: 20px;
  background: white;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(255,255,255,0.5);
  transition: left 0.6s ease;
}

.valuation-gauge-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
}

.gauge-zone {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.gauge-zone .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}

/* ===== FEAR & GREED ===== */
.fg-display {
  display: flex;
  align-items: center;
  gap: 32px;
}

.fg-gauge {
  position: relative;
  width: 180px;
  height: 100px;
  flex-shrink: 0;
}

.fg-gauge svg { width: 100%; height: 100%; }

.fg-number {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 42px;
  font-weight: 700;
}

.fg-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
}

.fg-details { flex: 1; }

.fg-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.fg-detail-name {
  font-size: 13px;
  color: var(--text-secondary);
}

.fg-detail-bar-container {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 55%;
}

.fg-detail-bar-bg {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.05);
  border-radius: 2px;
  overflow: hidden;
}

.fg-detail-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.8s ease;
}

.fg-detail-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  min-width: 28px;
  text-align: right;
}

/* ===== TREEMAP ===== */
.treemap-container {
  height: 420px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.treemap-cell {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 1px solid rgba(0,0,0,0.3);
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
}

.treemap-cell:hover {
  z-index: 10;
  filter: brightness(1.2);
  border-color: rgba(255,255,255,0.2);
}

.treemap-ticker {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  line-height: 1.2;
}

.treemap-pct {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.treemap-name {
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  max-width: 90%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.treemap-tooltip {
  display: none;
  position: fixed;
  background: rgba(18,18,26,0.95);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  z-index: 1000;
  pointer-events: none;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

/* ===== POLYMARKET ===== */
.poly-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.poly-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  transition: all 0.3s;
  cursor: pointer;
}

.poly-card:hover {
  border-color: rgba(168,85,247,0.3);
  background: rgba(168,85,247,0.04);
}

.poly-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.poly-question {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  flex: 1;
  padding-right: 12px;
}

.poly-volume {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
}

.poly-outcomes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.poly-outcome {
  display: flex;
  align-items: center;
  gap: 10px;
}

.poly-outcome-label {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 50px;
}

.poly-outcome-bar-bg {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.05);
  border-radius: 3px;
  overflow: hidden;
}

.poly-outcome-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1s ease;
}

.poly-outcome-pct {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  min-width: 40px;
  text-align: right;
}

.poly-tag {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(168,85,247,0.12);
  color: var(--purple);
  margin-bottom: 8px;
}

.poly-trend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  margin-top: 8px;
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 24px 0;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  margin-top: 12px;
  font-family: 'JetBrains Mono', monospace;
}

/* ===== LOADING ===== */
.loading-shimmer {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .grid-top, .grid-bottom { grid-template-columns: 1fr; }
  .dashboard { padding: 16px; }
  .nasdaq-value { font-size: 40px; }
  .treemap-container { height: 350px; }
  .fg-display { flex-direction: column; gap: 16px; }
}

@media (max-width: 640px) {
  .header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .nasdaq-sub { flex-wrap: wrap; gap: 16px; }
  .nasdaq-value { font-size: 32px; }
  .treemap-container { height: 280px; }
}
