:root {
  --bg: #0b0d10;
  --bg-elevated: #13161f;
  --bg-card: #1a1e29;
  --border: #2a2f3e;
  --text: #f0f2f5;
  --text-muted: #8b92a8;
  --accent: #00d4aa;
  --accent-dim: rgba(0, 212, 170, 0.15);
  --pulse: #e879f9;
  --positive: #10b981;
  --negative: #f87171;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

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

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Utilities */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

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

.mono {
  font-family: var(--font-mono);
}

.positive { color: var(--positive); }
.negative { color: var(--negative); }
.warning { color: var(--warning); }

/* Typography */
h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.3px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #00e6b8;
  color: #000;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* Focus */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  color: var(--text-muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

/* Forms */
.input {
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  width: 100%;
}

.input::placeholder {
  color: var(--text-muted);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab {
  padding: 10px 18px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--text);
  background: var(--bg-card);
}

.tab.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.timeframe-selector {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.timeframe-btn {
  padding: 6px 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.timeframe-btn:hover {
  color: var(--text);
}

.timeframe-btn.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.search-input {
  min-width: 240px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  justify-content: flex-end;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

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

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-ellipsis {
  color: var(--text-muted);
  padding: 0 8px;
}

.sparkline {
  display: block;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table th.sortable:hover {
  color: var(--text);
}

.data-table th.sorted::after {
  content: ' ▼';
  font-size: 10px;
  color: var(--accent);
}

.data-table th.sorted-asc::after {
  content: ' ▲';
}

.filters-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filters-bar #filter-tabs {
  flex: 1;
  min-width: 280px;
}

.filters-bar #filter-tabs .tabs {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

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

.hidden {
  display: none !important;
}

.portfolio-input-row {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.portfolio-input-row .input {
  flex: 1;
}

.learn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.learn-card h3 {
  font-size: 18px;
  margin-bottom: 12px;
}

.learn-card p {
  color: var(--text-muted);
  line-height: 1.6;
}

.learn-card dl {
  margin-top: 12px;
}

.learn-card dt {
  font-weight: 600;
  color: var(--text);
  margin-top: 10px;
}

.learn-card dd {
  color: var(--text-muted);
  margin-left: 0;
  margin-top: 4px;
}

.dex-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

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

.dex-card-header h4 {
  font-size: 18px;
}

.stats-grid.small .stat-value {
  font-size: 18px;
}

/* Loading */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Error / Empty */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.stream-row {
  animation: stream-flash 1.5s ease-out;
}

.chart-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

@keyframes stream-flash {
  0% {
    background-color: rgba(99, 102, 241, 0.18);
  }
  100% {
    background-color: transparent;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.api-base {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.api-base code {
  font-family: var(--font-mono);
  color: var(--accent);
}

.docs-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: start;
}

.docs-toc {
  position: sticky;
  top: 24px;
}

.docs-toc ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.docs-toc a {
  color: var(--text-muted);
  font-size: 14px;
}

.docs-toc a:hover {
  color: var(--accent);
}

.docs-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.endpoint h3 {
  margin-bottom: 12px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 18px;
}

.endpoint h4 {
  margin-top: 16px;
  margin-bottom: 8px;
  font-size: 15px;
}

.endpoint p {
  color: var(--text-muted);
  margin-bottom: 12px;
}

.endpoint pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  overflow-x: auto;
}

.endpoint code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
}

.endpoint ul {
  list-style: disc;
  padding-left: 20px;
  color: var(--text-muted);
}

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

  .docs-toc {
    position: static;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }

  .table-responsive .data-table {
    width: auto;
    min-width: 100%;
  }

  .data-table th,
  .data-table td {
    padding: 10px 12px;
    white-space: nowrap;
  }

  .tab {
    padding: 8px 12px;
    font-size: 13px;
  }
}
