:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --text: #e4e4e7;
  --text-muted: #9ca3af;
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

header {
  text-align: center;
  padding: 2rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-light), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

.header-actions {
  margin-top: 0.75rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.action-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--accent-light);
  padding: 0.4rem 1rem;
  border-radius: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}

.action-btn:hover {
  border-color: var(--accent-light);
  background: rgba(59,130,246,0.1);
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.data-status {
  font-size: 0.75rem;
  color: var(--text-muted);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* Snapshot cards */
.snapshot {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
}

.card h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.card.highlight {
  grid-column: 1 / -1;
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(59,130,246,0.08), rgba(167,139,250,0.08));
}

@media (min-width: 700px) {
  .card.highlight {
    grid-column: span 2;
  }
}

.card.highlight-secondary {
  grid-column: 1 / -1;
  border-color: #a78bfa;
  background: linear-gradient(135deg, rgba(167,139,250,0.08), rgba(59,130,246,0.08));
}

@media (min-width: 700px) {
  .card.highlight-secondary {
    grid-column: span 2;
  }
}

.card.highlight-secondary .big-number {
  color: #a78bfa;
}

.card.highlight-value {
  border-color: #22c55e;
  background: linear-gradient(135deg, rgba(34,197,94,0.08), rgba(16,185,129,0.08));
}

.card.highlight-value .big-number {
  color: #22c55e;
  font-size: 2rem;
  font-weight: 800;
}

.card.highlight-warning {
  border-color: #f59e0b;
  background: linear-gradient(135deg, rgba(245,158,11,0.08), rgba(234,88,12,0.08));
}

.card.highlight-warning .big-number {
  color: #f59e0b;
  font-size: 2rem;
  font-weight: 800;
}

.big-number {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--accent-light);
}

.big-number.secondary {
  font-size: 1.6rem;
  color: var(--text);
}

.detail {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.detail.usd-equiv {
  color: var(--success);
  font-weight: 600;
  font-size: 0.95rem;
  margin-top: 0.4rem;
}

/* Methodology */
.methodology {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

.methodology h3 {
  margin-bottom: 0.5rem;
  color: var(--accent-light);
}

.methodology p { margin-bottom: 0.3rem; }

.sources {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.sources a {
  color: var(--accent-light);
  text-decoration: none;
}

.sources a:hover { text-decoration: underline; }

/* Charts */
.chart-section {
  margin-bottom: 2.5rem;
}

.chart-section h2 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.chart-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.chart-header h2 {
  margin-bottom: 0;
}

.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  position: relative;
  height: 400px;
}

.chart-container.wide {
  height: 500px;
}

.chart-container.tall {
  height: 520px;
}

/* Protocol layout */
.protocol-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 768px) {
  .protocol-layout {
    grid-template-columns: 1fr;
  }
}

.protocol-pie {
  height: 400px;
}

.protocol-table-wrapper {
  max-height: 400px;
  overflow-y: auto;
}

.protocol-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  font-size: 0.85rem;
}

.protocol-table th {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-light);
  font-weight: 600;
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  position: sticky;
  top: 0;
}

.protocol-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.protocol-table tr:last-child td {
  border-bottom: none;
}

.protocol-table tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.protocol-color {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.protocol-link {
  color: var(--accent-light);
  text-decoration: none;
}

.protocol-link:hover {
  text-decoration: underline;
}

.chart-note {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 0.5rem;
}

/* Duration selector */
.duration-selector {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.duration-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.duration-btn:hover {
  border-color: var(--accent-light);
  color: var(--text);
}

.duration-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.duration-btn-b {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.duration-btn-b:hover {
  border-color: #a78bfa;
  color: var(--text);
}

.duration-btn-b.active {
  background: #a78bfa;
  border-color: #a78bfa;
  color: #fff;
}

/* Impact Table */
.table-intro {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

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

.impact-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  font-size: 0.88rem;
}

.impact-table th {
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-light);
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.impact-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.impact-table tr:last-child td {
  border-bottom: none;
}

.impact-table tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.impact-table tr.achieved {
  opacity: 0.5;
}

footer {
  text-align: center;
  padding: 2rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}

footer p { margin-bottom: 0.25rem; }

/* Loading spinner for refresh */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinning {
  display: inline-block;
  animation: spin 1s linear infinite;
}
