:root {
  --bg-base: #0a0a0f;
  --bg-surface: #12121a;
  --bg-elevated: #1a1a2e;
  --border-color: #2a2a3e;
  
  --color-primary: #00d4aa;
  --color-danger: #ff4757;
  --color-warning: #ffa502;
  
  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted: #555570;
  
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.3);
  
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --transition: all 0.2s ease;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
img { max-width: 100%; height: auto; display: block; }

/* Utilities */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

/* Typography */
h1, h2, h3 { color: var(--text-primary); font-weight: 600; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-2xl { font-size: 1.5rem; font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--color-primary); }
.text-danger { color: var(--color-danger); }
.text-center { text-align: center; }
.text-left { text-align: left; }
.m-0 { margin: 0; }

/* Components */
.nav {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 40;
}
.nav-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-brand {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-brand svg { fill: var(--color-primary); width: 24px; height: 24px; }

.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-md);
  border-color: #3a3a4e;
}
.card.elevated {
  background-color: var(--bg-elevated);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.875rem;
  border: none;
  transition: var(--transition);
}
.btn-primary {
  background-color: var(--color-primary);
  color: #000;
}
.btn-primary:hover { opacity: 0.9; }
.btn-danger {
  background-color: rgba(255, 71, 87, 0.1);
  color: var(--color-danger);
  border: 1px solid rgba(255, 71, 87, 0.2);
}
.btn-danger:hover { background-color: rgba(255, 71, 87, 0.2); }
.btn-outline {
  background-color: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-outline:hover { background-color: var(--bg-elevated); }
.btn-icon {
  padding: 8px;
  border-radius: var(--radius-full);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
}
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  z-index: 50;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.input, .select, .textarea {
  width: 100%;
  background-color: var(--bg-base);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  transition: var(--transition);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}
.textarea { min-height: 100px; resize: vertical; }

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-win { background-color: rgba(0, 212, 170, 0.15); color: var(--color-primary); border: 1px solid rgba(0, 212, 170, 0.3); }
.badge-loss { background-color: rgba(255, 71, 87, 0.15); color: var(--color-danger); border: 1px solid rgba(255, 71, 87, 0.3); }
.badge-be { background-color: rgba(255, 165, 2, 0.15); color: var(--color-warning); border: 1px solid rgba(255, 165, 2, 0.3); }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.tag-interactive { cursor: pointer; }
.tag-interactive:hover, .tag-interactive.active {
  background-color: var(--color-primary);
  color: #000;
  border-color: var(--color-primary);
}

/* Modals & Toasts */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  width: 90%;
  max-width: 400px;
  transform: scale(0.95);
  transition: var(--transition);
}
.modal-overlay.active .modal { transform: scale(1); }

.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  animation: slideUp 0.3s ease forwards;
}
.toast-success { border-left: 4px solid var(--color-primary); }
.toast-error { border-left: 4px solid var(--color-danger); }

/* Layout Specifics */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin: 24px 0;
}
.stat-card {
  text-align: center;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 8px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}
.filter-bar .input, .filter-bar .select { width: auto; min-width: 120px; }

.backtest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
.backtest-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card-win { border-left: 4px solid var(--color-primary); }
.card-loss { border-left: 4px solid var(--color-danger); }
.card-be { border-left: 4px solid var(--color-warning); }

.file-upload {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 40px 20px;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  background-color: var(--bg-base);
}
.file-upload:hover, .file-upload.dragover {
  border-color: var(--color-primary);
  background-color: rgba(0, 212, 170, 0.05);
}

.lightbox {
  position: fixed;
  inset: 0;
  background-color: rgba(0,0,0,0.9);
  z-index: 150;
  display: none;
  align-items: center;
  justify-content: center;
}
.lightbox.active { display: flex; }
.lightbox img { max-height: 90vh; max-width: 90vw; object-fit: contain; }

.spinner {
  border: 3px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  border-top: 3px solid var(--color-primary);
  width: 24px;
  height: 24px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Login Page */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; margin: 0 auto 16px; opacity: 0.5; }

/* Responsive */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filter-bar { flex-direction: column; }
  .filter-bar .input, .filter-bar .select { width: 100%; }
  .backtest-grid { grid-template-columns: 1fr; }
}

/* Screenshot Grid */
.screenshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.screenshot-grid img {
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border-color);
  aspect-ratio: 16/9;
  object-fit: cover;
  width: 100%;
}
.screenshot-grid img:hover {
  border-color: var(--color-primary);
  transform: scale(1.02);
}
.screenshot-item {
  position: relative;
}
.screenshot-item .delete-screenshot {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.7);
  border: none;
  color: var(--color-danger);
  padding: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0;
  transition: var(--transition);
}
.screenshot-item:hover .delete-screenshot {
  opacity: 1;
}

/* Tags Section */
.tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

/* Upload Preview */
.upload-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.upload-previews .preview-item {
  position: relative;
  width: 80px;
  height: 80px;
}
.upload-previews .preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}
.upload-previews .preview-item .remove-preview {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-danger);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
