:root {
  --bg: #0a1220;
  --bg-alt: #0f172a;
  --panel: #111b2e;
  --panel-2: #0f1a2b;
  --line: #27364d;
  --line-strong: #355074;
  --text: #e7efff;
  --text-soft: #c9d8f2;
  --text-muted: #93a7c8;
  --accent: #4fd1c5;
  --accent-hover: #63e6db;
  --positive: #34d399;
  --negative: #fb7185;
  --focus: #7db8ff;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
  --timing: 160ms ease;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(circle at 15% -10%, #142545 0%, transparent 45%),
    radial-gradient(circle at 88% 10%, #112238 0%, transparent 35%),
    var(--bg);
  color: var(--text);
  font-family: "Manrope", sans-serif;
  line-height: 1.45;
  padding: clamp(12px, 1.8vw, 24px);
}

.page {
  max-width: 1080px;
  margin: 0 auto;
}

.hero {
  margin: 0 0 1rem;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  font-weight: 800;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0.35rem 0 0;
  font-family: "Fraunces", serif;
  font-size: clamp(1.8rem, 2vw + 1.2rem, 2.9rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
  max-width: 16ch;
}

.subhead {
  margin: 0.6rem 0 0;
  color: var(--text-muted);
  max-width: 62ch;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  box-shadow: var(--shadow);
}

.controls {
  padding: 0.85rem;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(160px, 0.9fr);
  gap: 0.7rem;
  align-items: stretch;
}

.meta-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.62rem 0.72rem;
  background: #121f34;
}

.meta-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.meta-item strong {
  display: block;
  margin-top: 0.26rem;
  font-size: 1rem;
  font-weight: 800;
}

.refresh-btn {
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #062126;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  padding: 0.8rem 0.9rem;
  cursor: pointer;
  transition: background var(--timing), transform var(--timing), opacity var(--timing);
}

.refresh-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.refresh-btn:active:not(:disabled) {
  transform: translateY(0);
}

.refresh-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}

.api-note {
  margin: 0;
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.status-panel {
  margin-top: 0.75rem;
  padding: 0.72rem 0.88rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

#status-text {
  margin: 0;
  color: var(--text-soft);
  font-weight: 700;
}

#last-updated {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.accounts-grid {
  margin-top: 0.9rem;
}

.account-card {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: #0f1a2a;
  box-shadow: var(--shadow);
  padding: 0.95rem;
}

.account-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem;
}

.card-header {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.72rem;
  align-items: start;
}

.account-pager {
  flex-shrink: 0;
}

.account-pager .pager-btn {
  min-width: 2rem;
  padding: 0.24rem 0.42rem;
}

.account-pager .pager-info {
  min-width: 2.5rem;
  font-weight: 700;
}

.identity {
  min-width: 0;
}

.rank {
  margin: 0;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  background: #1e3658;
  color: #d5e6ff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.92rem;
  border: 1px solid #3d608d;
}

.username {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: clamp(1.18rem, 1.1vw + 0.95rem, 1.75rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.username-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--timing), color var(--timing);
}

.username-link:hover {
  color: var(--accent-hover);
  border-color: rgba(99, 230, 219, 0.7);
}

.wallet {
  margin: 0.3rem 0 0;
  color: var(--text-muted);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.wallet-label {
  margin-right: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.67rem;
  color: var(--text-muted);
  font-weight: 700;
}

.wallet-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted rgba(147, 167, 200, 0.6);
}

.wallet-link:hover {
  color: var(--text-soft);
  border-bottom-color: var(--text-soft);
}

.stats {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.stat {
  border: 1px solid #24405e;
  border-radius: var(--radius-md);
  background: #112235;
  padding: 0.58rem 0.72rem;
}

.stat-label {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
}

.pnl {
  margin-top: 0.22rem;
  display: inline-block;
  font-family: "Fraunces", serif;
  font-size: 1.6rem;
  color: var(--positive);
}

.pnl.loss {
  color: var(--negative);
}

.activity-count {
  margin-top: 0.22rem;
  display: inline-block;
  font-family: "Fraunces", serif;
  font-size: 1.25rem;
  color: var(--text-soft);
}

.accuracy-ratio {
  margin-top: 0.22rem;
  display: inline-block;
  font-family: "Fraunces", serif;
  font-size: 1.25rem;
  color: var(--text-soft);
}

.stat-note {
  display: block;
  margin-top: 0.18rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.bets-block {
  margin-top: 0.9rem;
}

.bets-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.bets-title {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.pager {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.pager-info {
  min-width: 3.2rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pager-btn {
  border: 1px solid #315278;
  border-radius: var(--radius-sm);
  background: #12243a;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.24rem 0.56rem;
  cursor: pointer;
  transition: border-color var(--timing), color var(--timing), background var(--timing);
}

.pager-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: #dffcf7;
  background: #17314b;
}

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

.bet-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.52rem;
}

.bet-list li {
  border: 1px solid #223953;
  border-radius: var(--radius-sm);
  background: #0d1d31;
  padding: 0.58rem 0.68rem;
  color: var(--text-soft);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bet-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
}

.bet-left {
  min-width: 0;
}

.bet-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.35rem;
}

.market-link {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(201, 216, 242, 0.4);
}

.market-link:hover {
  color: #f3f8ff;
  border-bottom-color: #f3f8ff;
}

.bet-right {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  text-align: right;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.bet-detail {
  white-space: nowrap;
}

.tag {
  display: inline-block;
  margin-right: 0.3rem;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  border: 1px solid #37666f;
  background: #123940;
  color: #b6f7ef;
  font-size: 0.67rem;
  font-weight: 700;
}

.error {
  color: #ffd0dc;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

@media (max-width: 980px) {
  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .refresh-btn {
    grid-column: span 2;
  }
}

@media (max-width: 860px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  body {
    padding: 12px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .refresh-btn {
    grid-column: auto;
  }

  .status-panel {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .account-card-top {
    flex-direction: column;
  }

  .bets-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .bet-row {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  .bet-right {
    justify-content: flex-start;
    text-align: left;
  }
}
