/* ===== Incentiv Design System ===== */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* Core Colors — matched from portal.incentiv.io */
  --primary: #FE7233;
  --primary-light: #FCF1EC;
  --primary-hover: #e5612a;

  --bg-body: #F8F6F3;
  --bg-card: #FFFFFF;
  --bg-sidebar: #FFFFFF;

  --border: #DFDFD8;
  --border-subtle: #EEEEE8;

  --text-primary: #1A1A1A;
  --text-secondary: #6B716D;
  --text-muted: #9CA3A0;

  /* Tier colors */
  --tier-diamond: #60A5FA;
  --tier-platinum: #A78BFA;
  --tier-gold: #F59E0B;
  --tier-silver: #94A3B8;
  --tier-bronze: #D97706;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 100px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== Layout ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 24px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  text-decoration: none;
}

.sidebar-logo svg,
.sidebar-logo img {
  width: 28px;
  height: auto;
  flex-shrink: 0;
}

.sidebar-logo span {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--primary-light);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.sidebar-footer .nav-item {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ===== Main Content ===== */
.main-content {
  margin-left: 240px;
  flex: 1;
  padding: 32px 40px;
  max-width: 1200px;
}

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

.page-subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ===== Stat Bar ===== */
.stat-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 20px;
  height: 20px;
  stroke: var(--primary);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.card-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header h2 svg {
  width: 20px;
  height: 20px;
  stroke: var(--primary);
}

.card-body {
  padding: 24px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
}

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

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

.btn-secondary {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.btn-secondary:hover {
  background: #fde4d6;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg-body);
  border-color: var(--text-muted);
}

.btn.loading {
  opacity: 0.65;
  pointer-events: none;
}

/* ===== Upload Section ===== */
.upload-section {
  padding: 24px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-body);
}

.dropzone:hover,
.dropzone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.dropzone-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone-icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--primary);
}

.dropzone-content p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.dropzone-content p strong {
  color: var(--primary);
  font-weight: 600;
}

.dropzone-content small {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.dropzone-file {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.dropzone-file .file-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.dropzone-file .file-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.dropzone-file .file-remove:hover {
  color: #ef4444;
  background: #fef2f2;
}

.dropzone-file .file-remove svg {
  width: 18px;
  height: 18px;
}

.upload-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.upload-result {
  font-size: 0.85rem;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

.upload-result.success {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.upload-result.error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

/* ===== Leaderboard Table ===== */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.leaderboard-table tbody tr {
  transition: background 0.12s ease;
  animation: fadeRow 0.3s ease forwards;
  opacity: 0;
}

@keyframes fadeRow {
  to {
    opacity: 1;
  }
}

.leaderboard-table tbody tr:hover {
  background: var(--primary-light);
}

.leaderboard-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.88rem;
}

.leaderboard-table tbody tr:last-child td {
  border-bottom: none;
}

/* Column alignments */
.th-rank,
.rank-cell {
  text-align: center;
  width: 70px;
}

.th-xp,
.xp-cell {
  text-align: right;
}

.th-tier,
.tier-cell {
  text-align: center;
}

.th-num,
.num-cell {
  text-align: center;
}

.th-updated,
.updated-cell {
  text-align: right;
}

/* Rank badge */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.82rem;
  background: var(--bg-body);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* Address */
.address-cell {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.84rem;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

/* XP */
.xp-cell {
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Updated */
.updated-cell {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Number cells */
.num-cell {
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ===== Tier Badges ===== */
.tier-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}

.tier-gold {
  background: rgba(245, 158, 11, 0.1);
  color: var(--tier-gold);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.tier-diamond {
  background: rgba(96, 165, 250, 0.1);
  color: var(--tier-diamond);
  border: 1px solid rgba(96, 165, 250, 0.25);
}

.tier-platinum {
  background: rgba(167, 139, 250, 0.1);
  color: var(--tier-platinum);
  border: 1px solid rgba(167, 139, 250, 0.25);
}

.tier-silver {
  background: rgba(148, 163, 184, 0.1);
  color: var(--tier-silver);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.tier-bronze {
  background: rgba(217, 119, 6, 0.1);
  color: var(--tier-bronze);
  border: 1px solid rgba(217, 119, 6, 0.25);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-state svg {
  width: 56px;
  height: 56px;
  stroke: var(--text-muted);
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ===== Add Wallet Section ===== */
.add-wallet-section {
  padding: 20px 24px;
}

.add-wallet-form {
  display: flex;
  gap: 10px;
}

.wallet-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--bg-body);
  outline: none;
  transition: border-color 0.15s ease;
}

.wallet-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(254, 114, 51, 0.08);
}

.wallet-input::placeholder {
  color: var(--text-muted);
  font-family: 'Plus Jakarta Sans', sans-serif;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  padding: 32px;
  width: 520px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(16px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-body);
}

.modal-close svg {
  width: 20px;
  height: 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.modal-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-icon svg {
  width: 22px;
  height: 22px;
  stroke: var(--primary);
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-address {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: var(--bg-body);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 20px;
  word-break: break-all;
  user-select: all;
}

.modal-warning {
  background: #FEF3CD;
  border: 1px solid #F59E0B;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #92400e;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-stat {
  background: var(--bg-body);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.modal-stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.modal-stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-stat-value .tier-badge {
  font-size: 0.82rem;
}

/* ===== Clickable Row ===== */
.leaderboard-table tbody tr {
  cursor: pointer;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .sidebar {
    display: none;
  }

  .main-content {
    margin-left: 0;
    padding: 20px 16px;
  }

  .stat-bar {
    flex-direction: column;
  }

  .leaderboard-table {
    display: block;
    overflow-x: auto;
  }

  .add-wallet-form {
    flex-direction: column;
  }

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

/* ===== Hidden utility ===== */
[hidden] {
  display: none !important;
}