:root {
  --green: #00A86B;
  --green-dark: #007A4D;
  --green-light: #E8F5E9;
  --gold: #FFB300;
  --gold-light: #FFF8E1;
  --red: #E53935;
  --bg: #FAFAFA;
  --card: #FFFFFF;
  --text: #212121;
  --text-secondary: #757575;
  --border: #E0E0E0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  color: white;
  padding: 20px 0;
  box-shadow: 0 2px 12px rgba(0,166,107,0.3);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.logo span { color: var(--gold); }
.wallet-connect { display: flex; align-items: center; gap: 8px; }
.btn-wallet { background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3); color: white; padding: 8px 16px; border-radius: 8px; font-weight: 600; cursor: pointer; font-family: inherit; font-size: 13px; transition: background 0.2s; }
.btn-wallet:hover { background: rgba(255,255,255,0.25); }
.wallet-connected { display: flex; align-items: center; gap: 8px; color: white; font-size: 13px; font-weight: 600; }
.wallet-dot { width: 8px; height: 8px; background: #4CAF50; border-radius: 50%; }
.network-badge { background: rgba(255,255,255,0.15); padding: 4px 8px; border-radius: 4px; font-size: 11px; }
.header-stats {
  display: flex;
  gap: 24px;
}
.stat-item {
  text-align: center;
}
.stat-value {
  font-size: 20px;
  font-weight: 700;
}
.stat-label {
  font-size: 11px;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Tab Navigation */
.tab-nav {
  background: var(--card);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.tab-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 0;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  font-family: inherit;
  white-space: nowrap;
}
.tab-btn:hover {
  color: var(--green);
}
.tab-btn.active {
  color: var(--green-dark);
  border-bottom-color: var(--green);
  font-weight: 700;
}

/* Tab Views */
.tab-view {
  display: none;
  opacity: 0;
}
.tab-view.active {
  display: block;
  animation: tabFadeIn 0.2s ease forwards;
}
@keyframes tabFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Hero */
.hero {
  background: linear-gradient(135deg, #004D40, var(--green-dark));
  color: white;
  padding: 48px 24px;
  text-align: center;
}
.hero h1 {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 12px;
}
.hero p {
  font-size: 18px;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto;
}

/* Main Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 1px solid var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.card-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.card-icon.green { background: var(--green-light); }
.card-icon.gold { background: var(--gold-light); }

/* Form */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-group select,
.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  transition: border-color 0.2s;
  background: white;
}
.form-group select:focus,
.form-group input:focus {
  outline: none;
  border-color: var(--green);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: white;
  box-shadow: 0 4px 12px rgba(0,166,107,0.3);
}
.btn-primary:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 20px rgba(0,166,107,0.4);
}
.btn-primary:active {
  transform: scale(0.98);
}
.btn-secondary {
  background: var(--green-light);
  color: var(--green-dark);
  border: 2px solid var(--green);
}
.btn-secondary:hover {
  background: var(--green);
  color: white;
}

/* Fee Comparison */
.fee-comparison {
  margin-top: 16px;
}
.fee-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
}
.fee-row.highlight {
  background: var(--green-light);
  border: 2px solid var(--green);
}
.fee-row.traditional {
  background: #FFF3F3;
  border: 1px solid #FFCDD2;
}
.fee-provider {
  font-weight: 600;
}
.fee-amount {
  font-weight: 700;
  font-size: 18px;
}
.fee-savings {
  color: var(--green);
  font-weight: 700;
  font-size: 14px;
}
.fee-expensive {
  color: var(--red);
  font-size: 14px;
}
.fee-bar {
  height: 8px;
  border-radius: 4px;
  margin-top: 6px;
}
.fee-bar.afripay { background: var(--green); }
.fee-bar.western { background: #FF6B6B; }
.fee-bar.banks { background: #EF5350; }

/* Agent Map */
.map-container {
  background: linear-gradient(180deg, #E3F2FD 0%, #E8F5E9 40%, #E8F5E9 100%);
  border-radius: 8px;
  height: 420px;
  position: relative;
  overflow: hidden;
  border: 1px solid #C8E6C9;
}
.map-africa {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.africa-svg {
  width: 100%;
  height: 100%;
  max-width: 700px;
}
.city-dot {
  cursor: pointer;
  transition: r 0.2s ease;
}
.city-dot:hover {
  r: 2.5;
  filter: drop-shadow(0 0 4px rgba(0,122,77,0.8));
}
.city-label {
  font-size: 2.2px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  fill: #333;
  pointer-events: none;
}
.pulse-dot {
  animation: svgPulse 2s ease-in-out infinite;
}
@keyframes svgPulse {
  0% { filter: drop-shadow(0 0 2px rgba(0,166,107,0.5)); }
  50% { filter: drop-shadow(0 0 6px rgba(0,166,107,0.9)); }
  100% { filter: drop-shadow(0 0 2px rgba(0,166,107,0.5)); }
}
.map-label {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(255,255,255,0.9);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

/* Agent list */
.agent-list {
  margin-top: 16px;
}
.agent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.agent-item:last-child { border-bottom: none; }
.agent-name { font-weight: 600; }
.agent-location { color: var(--text-secondary); font-size: 13px; }
.agent-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--green-light);
  color: var(--green-dark);
}

/* Transaction history */
.tx-table {
  width: 100%;
  border-collapse: collapse;
}
.tx-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
}
.tx-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-completed { background: var(--green-light); color: var(--green-dark); }
.status-pending { background: var(--gold-light); color: #F57F17; }
.status-claimed { background: #E3F2FD; color: #1565C0; }

/* Impact Metrics */
.impact-card {
  text-align: center;
  padding: 24px 16px;
}
.impact-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--green);
}
.impact-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.impact-sub {
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
}

/* Footer */
.footer {
  background: var(--text);
  color: white;
  padding: 32px 24px;
  text-align: center;
  margin-top: 48px;
}
.footer p { opacity: 0.7; font-size: 14px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--green);
  color: white;
  padding: 14px 24px;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  transform: translateY(100px);
  transition: transform 0.3s ease;
  z-index: 1000;
}
.toast.show { transform: translateY(0); }

/* Hero badge */
.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

/* Highlight green for impact values */
.impact-value.highlight-green {
  color: var(--green);
}

/* Fee banner */
.fee-banner {
  margin-bottom: 24px;
  padding: 28px;
}
.fee-banner-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  text-align: center;
}
.fee-banner-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fee-banner-item {
  display: grid;
  grid-template-columns: 140px 1fr 140px;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  border-radius: 8px;
}
.fee-banner-item.fee-banner-afripay {
  background: var(--green-light);
  border: 2px solid var(--green);
}
.fee-banner-provider {
  font-weight: 600;
  font-size: 14px;
}
.fee-banner-bar-container {
  background: #f0f0f0;
  border-radius: 4px;
  height: 20px;
  overflow: hidden;
}
.fee-banner-bar {
  height: 100%;
  border-radius: 4px;
  min-width: 4px;
}
.bar-afripay { background: var(--green); }
.bar-mobile { background: #FF9800; }
.bar-wu { background: #FF6B6B; }
.bar-bank { background: #EF5350; }
.fee-banner-cost {
  font-weight: 700;
  font-size: 16px;
  text-align: right;
}
.fee-pct {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.7;
}
.fee-banner-savings {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}
.green-text { color: var(--green); }
.red-text { color: var(--red); }

/* Flow card */
.flow-card {
  margin-bottom: 24px;
}
.flow-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.flow-step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  background: var(--green-light);
  border-radius: 10px;
}
.flow-number {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: var(--green);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
}
.flow-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}
.flow-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.flow-arrow {
  text-align: center;
  font-size: 20px;
  color: var(--green);
  padding: 4px 0;
  font-weight: 700;
}

/* (pulse animation moved to .pulse-dot in map section) */

/* ===================== LEADERBOARD ===================== */
.leaderboard-controls {
  margin-bottom: 16px;
}
.leaderboard-search {
  width: 100%;
  max-width: 300px;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}
.leaderboard-search:focus {
  outline: none;
  border-color: var(--green);
}
.sortable {
  cursor: pointer;
  user-select: none;
}
.sortable:hover {
  color: var(--green);
}
.sort-arrow {
  font-size: 10px;
  margin-left: 4px;
}
.star-display {
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 1px;
}
.star-display .star-empty {
  opacity: 0.3;
}

/* ===================== ANALYTICS CHARTS ===================== */

/* Horizontal Bar Chart */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.bar-chart-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.bar-chart-label {
  min-width: 110px;
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  color: var(--text);
  white-space: nowrap;
}
.bar-chart-track {
  flex: 1;
  height: 28px;
  background: #f0f0f0;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.bar-chart-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--green), var(--green-dark));
  transition: width 0.8s ease;
  min-width: 2px;
}
.bar-chart-fill.gold {
  background: linear-gradient(90deg, var(--gold), #FF8F00);
}
.bar-chart-value {
  min-width: 70px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

/* Status Distribution Chart */
.status-chart {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.status-bar-container {
  margin-bottom: 8px;
}
.status-bar-track {
  height: 40px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  margin-bottom: 12px;
}
.status-bar-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  transition: width 0.8s ease;
}
.status-bar-segment.completed { background: var(--green); }
.status-bar-segment.claimed { background: #1565C0; }
.status-bar-segment.pending { background: var(--gold); }
.status-legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.status-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.status-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.status-legend-dot.completed { background: var(--green); }
.status-legend-dot.claimed { background: #1565C0; }
.status-legend-dot.pending { background: var(--gold); }
.status-count {
  font-weight: 700;
  margin-left: 4px;
}

/* Savings Breakdown */
.savings-breakdown {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.savings-counter {
  text-align: center;
  padding: 24px 0;
}
.savings-counter-value {
  font-size: 48px;
  font-weight: 800;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}
.savings-counter-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}
.savings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--green-light);
  border-radius: 8px;
}
.savings-item-label {
  font-size: 13px;
  font-weight: 600;
}
.savings-item-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--green-dark);
}

/* Architecture Grid (How It Works) */
.architecture-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.arch-item {
  padding: 20px;
  background: var(--green-light);
  border-radius: 10px;
  border-left: 4px solid var(--green);
}
.arch-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 8px;
  color: var(--green-dark);
  font-family: monospace;
}
.arch-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Table row hover */
.tx-table tbody tr {
  transition: background-color 0.15s ease;
}
.tx-table tbody tr:hover {
  background-color: var(--green-light);
}

/* Focus styles for accessibility */
.btn:focus-visible,
.tab-btn:focus-visible,
.form-group select:focus-visible,
.form-group input:focus-visible,
.leaderboard-search:focus-visible,
.sortable:focus-visible,
.map-dot:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* Staggered fade-in for list items and table rows */
@keyframes staggerFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.stagger-in {
  animation: staggerFadeIn 0.25s ease forwards;
  opacity: 0;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
  .grid, .grid-3, .grid-4, .form-row { grid-template-columns: 1fr; }
  .header-stats { display: none; }
  .hero h1 { font-size: 24px; }
  .fee-banner-item { grid-template-columns: 100px 1fr 100px; }
  .tab-nav-inner { overflow-x: auto; }
  .tab-btn { padding: 12px 16px; font-size: 13px; }
  .architecture-grid { grid-template-columns: 1fr; }
  .bar-chart-label { min-width: 80px; font-size: 11px; }
  .bar-chart-value { min-width: 50px; font-size: 11px; }
  .savings-counter-value { font-size: 36px; }
}
