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

:root {
  --bg:       #080b10;
  --surface:  #0d1117;
  --surface2: #131920;
  --border:   #1e2733;
  --border2:  #243040;
  --text:     #e2e8f0;
  --muted:    #5a7080;
  --dim:      #8899aa;
  --green:    #10d98a;
  --green-dim:#0f9962;
  --red:      #f04f5e;
  --accent:   #6366f1;
  --accent2:  #818cf8;
  --yellow:   #f5c400;
  --mono:     'JetBrains Mono', monospace;
  --sans:     'Inter', sans-serif;
}

html { font-size: 14px; }

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

/* ── App ── */
.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.logo {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
  text-decoration: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tagline {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  display: block;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.updated {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

.btn-refresh {
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--dim);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

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

/* ── Controls ── */
.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.search {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
}

.search:focus { border-color: var(--accent); }
.search::placeholder { color: var(--muted); }

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.chain-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chain-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 100px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}

.chain-btn:hover { border-color: var(--border2); color: var(--dim); }
.chain-btn.active { border-color: var(--accent); color: var(--accent2); background: rgba(99,102,241,0.08); }

.right-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-label {
  font-size: 12px;
  color: var(--muted);
  user-select: none;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input { display: none; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border2);
  border-radius: 18px;
  transition: background 0.2s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-track { background: var(--accent); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(14px); }

.sort-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--dim);
  font-family: var(--sans);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}

/* ── Stats bar ── */
.stats-bar {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.stat-value.green { color: var(--green); }

/* ── Table ── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  overflow-x: auto;
  background: var(--surface);
}

.loading, .empty {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px;
  color: var(--muted);
  font-size: 14px;
}

.loading { display: flex; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  display: none;
  table-layout: auto;
}

table.visible { display: table; }

thead tr {
  border-bottom: 1px solid var(--border);
}

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

th.num { text-align: right; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

td {
  padding: 11px 14px;
  white-space: nowrap;
}

td.num { text-align: right; font-family: var(--mono); }

/* Protocol */
.protocol-name {
  font-weight: 500;
  color: var(--text);
  text-transform: capitalize;
}

.protocol-link {
  font-weight: 500;
  color: var(--text);
  text-transform: capitalize;
  text-decoration: none;
  border-bottom: 1px solid var(--border2);
  transition: color 0.15s, border-color 0.15s;
}

.protocol-link:hover {
  color: var(--accent2);
  border-bottom-color: var(--accent2);
}

.protocol-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pool-link {
  font-size: 10px;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}

tr:hover .pool-link { opacity: 1; }
.pool-link:hover { color: var(--accent2); }

/* Token */
.token-badge {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent2);
  background: rgba(99,102,241,0.1);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Chain */
.chain-tag {
  font-size: 11px;
  color: var(--dim);
}

/* APY */
.apy-total {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--green);
}

.apy-total.high { color: var(--green); }
.apy-total.mid  { color: var(--yellow); }
.apy-total.low  { color: var(--dim); }

.apy-base, .apy-reward {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
}

.apy-reward.nonzero { color: var(--yellow); }

/* TVL */
.tvl {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
}

/* Exposure */
.exposure {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.exposure.single { color: var(--green-dim); background: rgba(16,217,138,0.07); }
.exposure.multi  { color: var(--muted);     background: rgba(255,255,255,0.04); }

/* IL Risk */
.il {
  font-size: 11px;
  font-weight: 500;
}

.il.no   { color: var(--green-dim); }
.il.low  { color: var(--yellow); }
.il.high { color: var(--red); }
.il.yes  { color: var(--red); }

/* Notes */
.notes {
  font-size: 11px;
  color: var(--muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sort headers */
th[data-sort] {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th[data-sort]:hover { color: var(--dim); }

th[data-sort]::after {
  content: '';
  display: inline-block;
  margin-left: 5px;
  opacity: 0;
  font-size: 9px;
}

th.sort-desc::after { content: '↓'; opacity: 1; color: var(--accent2); }
th.sort-asc::after  { content: '↑'; opacity: 1; color: var(--accent2); }
th.sort-desc, th.sort-asc { color: var(--accent2); }

/* 7d change */
.change-up      { font-family: var(--mono); font-size: 12px; color: var(--green); }
.change-down    { font-family: var(--mono); font-size: 12px; color: var(--red); }
.change-neutral { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ── Footer ── */
.footer {
  margin-top: 20px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
