:root {
  --bg: #080c18;
  --surface: #0f1625;
  --surface2: #172033;
  --border: #1c2a3f;
  --purple: #9945ff;
  --green: #14f195;
  --text: #dde5f0;
  --text2: #8a9ab5;
  --text3: #4d5e7a;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
  background: linear-gradient(135deg, var(--surface) 0%, rgba(153, 69, 255, 0.03) 100%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--purple);
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.epoch-info {
  font-size: 12px;
  color: var(--text2);
  display: flex;
  gap: 24px;
}

.epoch-info span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.epoch-info strong {
  color: var(--text);
  font-weight: 600;
}

main {
  max-width: 1380px;
  margin: 0 auto;
  padding: 24px 20px;
}

.search-section {
  margin-bottom: 24px;
}

.search-box {
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  transition: border-color 0.2s;
}

.search-box:focus-within {
  border-color: var(--purple);
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-family: 'Courier New', monospace;
  outline: none;
  font-size: 14px;
}

.search-box input::placeholder {
  color: var(--text3);
}

.search-box button {
  background: var(--purple);
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.search-box button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 16px;
  align-items: start;
}

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

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
  border-color: rgba(153, 69, 255, 0.2);
}

.wallet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.tab {
  background: none;
  border: none;
  color: var(--text3);
  padding: 10px 14px;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--text2);
}

.tab.active {
  color: var(--purple);
  border-bottom-color: var(--purple);
}

.tab-content {
  animation: fadeIn 0.2s;
}

.tab-content.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.type-breakdown {
  margin-top: 16px;
}

.type-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  overflow: hidden;
}

.type-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.type-header:hover {
  background: rgba(153, 69, 255, 0.1);
}

.type-name {
  font-weight: 600;
  color: var(--purple);
}

.type-count {
  font-size: 12px;
  background: var(--border);
  padding: 2px 8px;
  border-radius: 12px;
  color: var(--text2);
}

.type-toggle {
  color: var(--text3);
  width: 20px;
  text-align: center;
  transition: transform 0.2s;
}

.type-toggle.open {
  transform: rotate(90deg);
}

.type-details {
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border);
  padding: 12px;
  max-height: 400px;
  overflow-y: auto;
  display: none;
}

.type-details.open {
  display: block;
}

.detail-tx {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.detail-tx:last-child {
  border-bottom: none;
}

.detail-tx a {
  color: var(--purple);
  word-break: break-all;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
  letter-spacing: -0.3px;
}

.hidden {
  display: none !important;
}

.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 60px 40px;
  text-align: center;
}

.empty-icon {
  font-size: 48px;
  color: var(--text3);
  margin-bottom: 16px;
}

.empty-text {
  font-size: 14px;
  color: var(--text2);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.stat-label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--green);
}

.tx-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.tx-item:last-child {
  border-bottom: none;
}

.tx-type {
  font-size: 12px;
  font-weight: 600;
  color: var(--purple);
  margin-bottom: 4px;
}

.tx-info {
  font-size: 11px;
  color: var(--text2);
  font-family: 'Courier New', monospace;
  word-break: break-all;
}

.tx-info a {
  color: var(--purple);
  word-break: break-all;
}

.tx-time {
  font-size: 10px;
  color: var(--text3);
  margin-top: 4px;
}

.validator-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.validator-row:last-child {
  border-bottom: none;
}

.validator-addr {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--text2);
  flex: 1;
}

.validator-stake {
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  text-align: right;
  min-width: 80px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  margin-left: 8px;
}

.badge-active {
  background: rgba(20, 241, 149, 0.1);
  color: var(--green);
}

.badge-delinquent {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.loading {
  color: var(--text2);
  text-align: center;
  padding: 20px;
}

.error {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 12px;
}

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

a:hover {
  text-decoration: underline;
}

.flux-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.flux-row:last-child {
  border-bottom: none;
}

.flux-addr {
  font-family: 'Courier New', monospace;
  color: var(--text2);
  flex: 1;
}

.flux-change {
  text-align: right;
  min-width: 100px;
  font-weight: 600;
}

.flux-positive {
  color: #14f195;
}

.flux-negative {
  color: #ef4444;
}

/* Stake History Cards */
.stake-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
  transition: background 0.2s;
}

.stake-card:hover {
  background: rgba(153, 69, 255, 0.05);
  border-color: rgba(153, 69, 255, 0.2);
}

.stake-info {
  flex: 1;
}

.stake-validator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.stake-validator-name {
  font-weight: 600;
  color: var(--purple);
  font-size: 13px;
  font-family: 'Courier New', monospace;
}

.stake-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.stake-status.active {
  background: rgba(20, 241, 149, 0.1);
  color: var(--green);
}

.stake-status.deactivating {
  background: rgba(234, 179, 8, 0.1);
  color: #eab308;
}

.stake-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 8px;
}

.stake-detail {
  font-size: 11px;
}

.stake-detail-label {
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.stake-detail-value {
  color: var(--text);
  font-weight: 600;
  word-break: break-all;
}

.stake-amount {
  text-align: right;
}

.stake-amount-label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stake-amount-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--green);
}

/* Timeline */
.timeline-container {
  position: relative;
  padding: 20px 0;
}

.timeline-item {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  position: relative;
}

.timeline-marker {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--purple);
  border: 2px solid var(--surface);
  flex-shrink: 0;
  margin-top: 6px;
  position: relative;
  z-index: 1;
}

.timeline-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 20px;
  width: 2px;
  height: calc(100% + 8px);
  background: var(--border);
}

.timeline-content {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}

.timeline-type {
  font-weight: 600;
  color: var(--purple);
  font-size: 12px;
  margin-bottom: 4px;
}

.timeline-time {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 8px;
}

.timeline-detail {
  font-size: 11px;
  color: var(--text2);
  word-break: break-all;
}

/* Loading states */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, rgba(153, 69, 255, 0.1) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: loading 2s infinite;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  height: 100px;
  margin-bottom: 12px;
  border-radius: 8px;
}

.skeleton-line {
  height: 12px;
  margin-bottom: 8px;
  border-radius: 4px;
}

@media (max-width: 640px) {
  .stake-card {
    grid-template-columns: 1fr;
  }

  .stake-amount {
    text-align: left;
  }

  .stake-details {
    grid-template-columns: 1fr;
  }
}

/* ── Right column single-column layout ── */
.col-left {
  min-width: 0;
}
.col-middle {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.col-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

/* Notable Events card */
.right-card-notable {
  max-height: 380px;
  display: flex;
  flex-direction: column;
}
.right-card-notable > div:last-child {
  overflow-y: auto;
  flex: 1;
}

/* Top Movers card */
.right-card-movers {
  max-height: 340px;
  display: flex;
  flex-direction: column;
}
.right-card-movers > div:last-child {
  overflow-y: auto;
  flex: 1;
}

/* Top Validators — smaller, less prominent */
.right-card-validators {
  max-height: 300px;
  display: flex;
  flex-direction: column;
  opacity: 0.85;
}
.right-card-validators > div:last-child {
  overflow-y: auto;
  flex: 1;
}
.right-card-validators .card-title {
  font-size: 13px;
  margin-bottom: 12px;
}

/* Activity Summary card */
.right-card-summary {
  padding: 16px 24px;
}

/* Card title variants */
.card-title-sm {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
}
.card-title-muted {
  color: var(--text2);
}
.card-title-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--text3);
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Activity Summary grid */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.summary-stat {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}
.summary-stat-label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.summary-stat-value {
  font-size: 15px;
  font-weight: 700;
}

/* Notable Events items */
.notable-event {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.notable-event:last-child {
  border-bottom: none;
}
.notable-event-left {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.notable-icon {
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  margin-top: 1px;
}
.notable-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.notable-meta {
  font-size: 10px;
  color: var(--text3);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.notable-addr {
  color: var(--text3);
  font-family: 'Courier New', monospace;
}
.notable-addr:hover {
  color: var(--text2);
}
.notable-validator {
  color: var(--purple);
  font-family: 'Courier New', monospace;
}
.notable-event-right {
  text-align: right;
  flex-shrink: 0;
}
.notable-amount {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 2px;
}
.notable-time {
  font-size: 10px;
  color: var(--text3);
  margin-bottom: 2px;
}
.notable-sig {
  font-size: 9px;
  color: var(--purple);
  font-family: 'Courier New', monospace;
}

/* Scrollbar for right cards */
.col-right ::-webkit-scrollbar {
  width: 5px;
}
.col-right ::-webkit-scrollbar-thumb {
  background: rgba(120, 160, 255, 0.25);
  border-radius: 4px;
}

/* Vote account disclaimer note */
.vote-account-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: rgba(153, 69, 255, 0.07);
  border: 1px solid rgba(153, 69, 255, 0.25);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text2);
  margin-top: 12px;
  margin-bottom: 4px;
  line-height: 1.5;
}
.vote-account-note em {
  font-style: italic;
}
.vote-account-note-icon {
  color: var(--purple);
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Mobile optimizations ── */
@media (max-width: 768px) {
  header {
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 8px;
  }

  .header-left {
    gap: 10px;
  }

  .logo { font-size: 16px; }
  .subtitle { display: none; }

  /* Hide ticker on mobile — too narrow */
  #ticker-wrap { display: none !important; }

  /* Epoch info compact on mobile */
  .epoch-info {
    width: 100%;
    gap: 12px;
    font-size: 11px;
  }

  /* Force grid to single column on mobile */
  .grid {
    grid-template-columns: 1fr !important;
  }

  main {
    padding: 12px 12px;
  }

  /* Cards less padding on mobile */
  .card {
    padding: 14px;
  }

  .right-card-summary {
    max-height: none;
  }
}
