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

:root {
  --bg: #0b0e14;
  --bg2: #131720;
  --bg3: #1a2030;
  --border: #232d40;
  --text: #e2e8f0;
  --text2: #8896ab;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --pink: #ff007a;
  --blue: #3b82f6;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

html { font-size: 15px; }
body { background: var(--bg); color: var(--text); font-family: 'Inter', sans-serif; min-height: 100vh; }
.mono { font-family: 'JetBrains Mono', monospace; }
.hidden { display: none !important; }
.green { color: var(--green); }
.red { color: var(--red); }

/* ── Header ── */
.header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1100px; margin: 0 auto;
  padding: 0 24px;
  height: 58px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.header-right { display: flex; align-items: center; gap: 12px; }

.wallet-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  color: var(--text2);
}

.refresh-group { display: flex; align-items: center; gap: 8px; }
.last-updated { font-size: 0.75rem; color: var(--text2); }

.btn-refresh {
  display: flex; align-items: center; gap: 5px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px;
  font-size: 0.8rem; color: var(--text); cursor: pointer;
  transition: background 0.15s;
}
.btn-refresh:hover { background: var(--border); }
.btn-refresh.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Main ── */
.main { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }

/* ── Loading / Error ── */
.loading-state, .error-state {
  text-align: center; padding: 80px 20px; color: var(--text2);
}
.spinner {
  width: 40px; height: 40px; border: 3px solid var(--border);
  border-top-color: var(--pink); border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
.error-icon { font-size: 2.5rem; margin-bottom: 12px; }
.error-state button {
  margin-top: 16px; background: var(--pink); border: none;
  border-radius: 8px; padding: 8px 20px; color: white; cursor: pointer; font-size: 0.9rem;
}

/* ── Summary Grid ── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px; margin-bottom: 28px;
}
.summary-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px;
}
.summary-card.accent { border-color: rgba(255,0,122,0.4); background: rgba(255,0,122,0.05); }
.summary-label { font-size: 0.78rem; color: var(--text2); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.04em; }
.summary-value { font-size: 1.6rem; font-weight: 700; }

/* ── Positions ── */
.positions { display: flex; flex-direction: column; gap: 20px; }

.pos-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}

.pos-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}
.pos-title-group { display: flex; align-items: center; gap: 12px; }
.pos-pool-name { font-size: 1.15rem; font-weight: 700; }
.pos-fee-badge {
  font-size: 0.72rem; font-weight: 600;
  padding: 3px 8px; border-radius: 20px;
  background: rgba(255,255,255,0.07);
  color: var(--text2);
}
.chain-badge {
  font-size: 0.72rem; font-weight: 600;
  padding: 3px 9px; border-radius: 20px;
  color: white;
}
.status-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.8rem; font-weight: 600;
  padding: 5px 12px; border-radius: 20px;
}
.status-badge.in { background: rgba(34,197,94,0.12); color: var(--green); }
.status-badge.out { background: rgba(239,68,68,0.12); color: var(--red); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; }
.status-badge.in .status-dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-badge.out .status-dot { background: var(--red); box-shadow: 0 0 6px var(--red); }

/* Body grid */
.pos-body {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
}
@media (max-width: 700px) { .pos-body { grid-template-columns: 1fr; } }

.pos-section {
  padding: 18px 22px;
  border-right: 1px solid var(--border);
}
.pos-section:last-child { border-right: none; }
.pos-section-title {
  font-size: 0.72rem; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 12px;
}

/* Token amounts */
.token-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.token-sym { font-weight: 600; font-size: 0.9rem; }
.token-amt { font-family: 'JetBrains Mono', monospace; font-size: 0.88rem; }
.token-usd { color: var(--text2); font-size: 0.78rem; }
.pos-total { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 10px; }
.pos-total .label { font-size: 0.78rem; color: var(--text2); }
.pos-total .value { font-size: 1.05rem; font-weight: 700; }

/* Fees section */
.fee-usd { font-size: 1.5rem; font-weight: 700; color: var(--green); margin-bottom: 8px; }
.fee-detail { font-size: 0.82rem; color: var(--text2); line-height: 1.6; font-family: 'JetBrains Mono', monospace; }

/* Price section */
.price-current { font-size: 1.25rem; font-weight: 700; margin-bottom: 6px; font-family: 'JetBrains Mono', monospace; }
.price-label { font-size: 0.75rem; color: var(--text2); margin-bottom: 14px; }
.price-range-bar { position: relative; margin: 8px 0 12px; }
.range-track {
  height: 6px; background: var(--bg3); border-radius: 3px;
  position: relative; overflow: visible;
}
.range-fill { height: 100%; border-radius: 3px; background: var(--green); }
.range-fill.out { background: var(--red); }
.range-cursor {
  position: absolute; top: -5px; width: 16px; height: 16px;
  background: white; border: 2px solid var(--bg); border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 0 2px var(--pink);
}
.range-limits { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--text2); font-family: 'JetBrains Mono', monospace; }

/* PnL section (full-width) */
.pos-pnl {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.015);
}
.pnl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.pnl-item { }
.pnl-item .label { font-size: 0.72rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.pnl-item .val { font-size: 1.1rem; font-weight: 600; }
.pnl-item .sub { font-size: 0.75rem; color: var(--text2); margin-top: 2px; }
.pnl-net { font-size: 1.3rem !important; }
.pnl-since { font-size: 0.72rem; color: var(--text2); margin-top: 10px; }

/* Footer */
.footer {
  text-align: center; padding: 24px;
  font-size: 0.75rem; color: var(--text2);
  border-top: 1px solid var(--border);
}
