:root {
  --bg-dark: #0B0F19;
  --bg-card: rgba(17, 24, 39, 0.78);
  --bg-card-hover: rgba(31, 41, 55, 0.88);
  --border-glass: rgba(255, 255, 255, 0.09);
  --border-glass-bright: rgba(255, 255, 255, 0.2);
  
  --text-main: #F9FAFB;
  --text-muted: #9CA3AF;
  --text-dim: #6B7280;

  --profit-color: #10B981;
  --profit-glow: rgba(16, 185, 129, 0.25);
  --loss-color: #EF4444;
  --loss-glow: rgba(239, 68, 68, 0.25);

  --gold-color: #F59E0B;
  --gold-glow: rgba(245, 158, 11, 0.35);
  --silver-color: #94A3B8;
  --silver-glow: rgba(148, 163, 184, 0.25);
  --bronze-color: #D97706;
  --bronze-glow: rgba(217, 119, 6, 0.25);

  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', system-ui, -apple-system, sans-serif;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(245, 158, 11, 0.06) 0%, transparent 40%);
  background-attachment: fixed;
}

.app-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Glassmorphism utility */
.glass-card, .glass-modal {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(17, 24, 39, 0.75);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #10B981, #047857);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: #fff;
  box-shadow: 0 0 14px var(--profit-glow);
}

.brand-info h1 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #FFFFFF, #9CA3AF);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
}

.sub-title {
  font-size: 0.72rem;
  color: var(--profit-color);
  font-weight: 600;
}

/* User Pill */
.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.2s ease;
  max-width: 160px;
}

.user-pill:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-glass-bright);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--profit-color);
  flex-shrink: 0;
}

.user-pill-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-rank-badge {
  font-size: 0.68rem;
  color: var(--gold-color);
  font-weight: 700;
  line-height: 1;
}

/* Period Tabs */
.period-tabs-container {
  width: 100%;
  margin-bottom: 14px;
}

.period-tabs {
  display: flex;
  gap: 6px;
  background: rgba(17, 24, 39, 0.65);
  padding: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

.tab-btn {
  flex: 1;
  padding: 9px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-align: center;
}

.tab-btn.active {
  background: var(--profit-color);
  color: #000;
  font-weight: 700;
  box-shadow: 0 4px 14px var(--profit-glow);
}

/* Overview Stats Grid with Expanded Spacing */
.stats-overview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  transition: transform 0.2s ease;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.profit-icon { background: rgba(16, 185, 129, 0.15); color: var(--profit-color); }
.trades-icon { background: rgba(59, 130, 246, 0.15); color: #3B82F6; }
.winrate-icon { background: rgba(245, 158, 11, 0.15); color: var(--gold-color); }
.traders-icon { background: rgba(168, 85, 247, 0.15); color: #A855F7; }

.stat-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

/* Podium Section with Expanded Spacing */
.podium-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-title h2, .section-header h2 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.text-amber { color: var(--gold-color); }

.podium-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 14px;
  padding: 10px 0;
}

.podium-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  position: relative;
  transition: all 0.3s ease;
  min-width: 0;
}

.gold-podium {
  order: 2;
  transform: scale(1.05);
  border-color: var(--gold-color);
  box-shadow: 0 0 20px var(--gold-glow);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.14) 0%, var(--bg-card) 100%);
}

.silver-podium { order: 1; border-color: var(--silver-color); }
.bronze-podium { order: 3; border-color: var(--bronze-color); }

.crown-icon {
  font-size: 1.4rem;
  margin-bottom: -4px;
  animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.podium-rank-badge {
  position: absolute;
  top: -10px;
  right: -5px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.8rem;
  color: #000;
}

.gold-podium .podium-rank-badge { background: var(--gold-color); }
.silver-podium .podium-rank-badge { background: var(--silver-color); }
.bronze-podium .podium-rank-badge { background: var(--bronze-color); }

.avatar-wrapper {
  margin-bottom: 8px;
}

.podium-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-glass);
}

.gold-glow .podium-avatar {
  width: 52px;
  height: 52px;
  border-color: var(--gold-color);
}

.podium-name {
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-pnl {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.92rem;
  margin-top: 3px;
  white-space: nowrap;
}

.gold-text { color: var(--gold-color); }

.podium-trades {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Leaderboard List with Spacing */
.leaderboard-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.traders-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  cursor: pointer;
}

.leaderboard-item:hover, .leaderboard-item:active {
  background: var(--bg-card-hover);
  border-color: var(--border-glass-bright);
}

.leader-left {
  display: flex;
  align-items: center;
  gap: 14px;
  overflow: hidden;
}

.rank-num {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  width: 22px;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
}

.leader-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.leader-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 2px;
}

.leader-name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.you-badge {
  font-size: 0.72rem;
  color: var(--profit-color);
  font-weight: 700;
}

.leader-meta {
  font-size: 0.73rem;
  color: var(--text-muted);
}

.leader-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
  margin-left: 10px;
}

.leader-pnl {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.98rem;
}

/* Empty State Card */
.empty-state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 18px;
  gap: 10px;
  border-radius: var(--radius-lg);
}

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.12);
  color: var(--profit-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.empty-state-card h4 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
}

.empty-state-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
  max-width: 340px;
}

.empty-state-card code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--profit-color);
}

/* Chart Section */
.chart-section {
  padding: 20px;
  margin-top: 10px;
  margin-bottom: 28px;
}

.chart-wrapper {
  margin-top: 12px;
  height: 190px;
  position: relative;
}

/* FAB Button */
.fab-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: linear-gradient(135deg, #10B981, #059669);
  color: #fff;
  border: none;
  padding: 14px 22px;
  border-radius: 30px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 20px var(--profit-glow);
  cursor: pointer;
  z-index: 99;
  transition: transform 0.2s ease;
}

.fab-btn:active {
  transform: scale(0.95);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 999;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
  transform: translateY(20px);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-glass);
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: 14px;
}

.modal-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--profit-color);
}

.profile-details h4 {
  font-size: 1rem;
  font-weight: 700;
}

.rank-tag {
  font-size: 0.78rem;
  color: var(--gold-color);
  font-weight: 600;
}

.user-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  padding: 14px;
  border-radius: var(--radius-md);
}

.mini-stat {
  display: flex;
  flex-direction: column;
}

.mini-label { font-size: 0.72rem; color: var(--text-muted); }
.mini-val { font-family: var(--font-heading); font-size: 0.95rem; font-weight: 700; }
.text-green { color: var(--profit-color); }
.text-red { color: var(--loss-color); }

.trades-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

.undo-btn {
  background: rgba(239, 68, 68, 0.15);
  color: var(--loss-color);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.trades-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.trade-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

/* Log Trade Form */
.type-selector {
  display: flex;
  gap: 10px;
}

.type-btn {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.profit-type.active {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--profit-color);
  color: var(--profit-color);
}

.loss-type.active {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--loss-color);
  color: var(--loss-color);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.form-group input {
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.95rem;
  font-family: var(--font-family);
  outline: none;
}

.form-group input:focus {
  border-color: var(--profit-color);
}

.submit-trade-btn {
  background: linear-gradient(135deg, #10B981, #047857);
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  margin-top: 6px;
}

/* Spinner */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
