/* ===== APP STYLES ===== */
:root {
  --bg: #0a0e1a;
  --bg2: #0f1526;
  --bg3: #151d35;
  --card: #111827;
  --border: #1e2d4a;
  --accent: #6c63ff;
  --accent2: #00d4aa;
  --accent-glow: rgba(108, 99, 255, 0.3);
  --text: #f0f4ff;
  --text2: #8892a4;
  --text3: #4a5568;
  --green: #00d4aa;
  --red: #ff4d6d;
  --yellow: #ffd166;
  --radius: 12px;
}

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

a { text-decoration: none; color: inherit; }

/* ===== AUTH PAGES ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  top: -200px; left: 50%;
  transform: translateX(-50%);
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(108,99,255,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
  position: relative;
}

.auth-logo {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  margin-bottom: 8px;
}

.auth-card h2 {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
}

.auth-card .auth-sub {
  text-align: center;
  color: var(--text2);
  font-size: 14px;
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.1);
}

.form-group input::placeholder { color: var(--text3); }

.btn {
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  width: 100%;
  padding: 13px;
  font-size: 15px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--bg3); }

.btn-danger {
  background: rgba(255, 77, 109, 0.1);
  color: var(--red);
  border: 1px solid rgba(255, 77, 109, 0.3);
}

.btn-danger:hover { background: rgba(255,77,109,0.2); }

.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 8px; }

.auth-link {
  text-align: center;
  font-size: 13px;
  color: var(--text2);
  margin-top: 24px;
}

.auth-link a { color: var(--accent); font-weight: 600; }
.auth-link a:hover { text-decoration: underline; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text3);
  font-size: 12px;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 20px;
  display: none;
}

.alert.show { display: block; }
.alert-error { background: rgba(255,77,109,0.1); border: 1px solid rgba(255,77,109,0.3); color: var(--red); }
.alert-success { background: rgba(0,212,170,0.1); border: 1px solid rgba(0,212,170,0.3); color: var(--green); }

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

/* ===== SIDEBAR ===== */
.sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 50;
  transition: transform 0.3s;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 8px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text3);
  padding: 0 20px;
  margin-bottom: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 0;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text);
}

.nav-item.active {
  color: var(--accent);
  background: rgba(108,99,255,0.08);
  border-left-color: var(--accent);
}

.nav-item .nav-icon { font-size: 17px; width: 20px; text-align: center; }

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

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; }
.user-plan { font-size: 11px; color: var(--text3); }

.btn-logout {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-logout:hover { background: rgba(255,77,109,0.1); color: var(--red); border-color: rgba(255,77,109,0.3); }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: 240px;
  flex: 1;
  min-height: 100vh;
}

.page-header {
  padding: 28px 32px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
}

.page-title { font-size: 22px; font-weight: 800; }
.page-sub { font-size: 13px; color: var(--text2); margin-top: 2px; }

.page-body { padding: 28px 32px; }

/* ===== METRIC CARDS ===== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  transition: border-color 0.2s;
}

.metric-card:hover { border-color: rgba(108,99,255,0.3); }

.metric-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.metric-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 6px;
}

.metric-value.green { color: var(--green); }
.metric-value.red { color: var(--red); }
.metric-value.purple { color: var(--accent); }
.metric-value.yellow { color: var(--yellow); }

.metric-change {
  font-size: 12px;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 4px;
}

.metric-change.up { color: var(--green); }
.metric-change.down { color: var(--red); }

/* ===== CHARTS ===== */
.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.chart-card-title { font-size: 16px; font-weight: 700; }
.chart-card-sub { font-size: 12px; color: var(--text3); }

.chart-area {
  width: 100%;
  height: 240px;
  position: relative;
}

/* ===== TABLES ===== */
.table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.table-title { font-size: 16px; font-weight: 700; }

.table-filters {
  display: flex;
  gap: 10px;
  align-items: center;
}

.filter-input {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.filter-input:focus { border-color: var(--accent); }
.filter-input::placeholder { color: var(--text3); }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid rgba(30, 45, 74, 0.5);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: rgba(255,255,255,0.02); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.badge-green { background: rgba(0,212,170,0.12); color: var(--green); }
.badge-red { background: rgba(255,77,109,0.12); color: var(--red); }
.badge-purple { background: rgba(108,99,255,0.12); color: var(--accent); }
.badge-gray { background: rgba(255,255,255,0.06); color: var(--text3); }

.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-muted { color: var(--text3); }

.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text3);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text2); margin-bottom: 8px; }
.empty-state p { font-size: 14px; margin-bottom: 24px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.2s;
}

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

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

.modal-title { font-size: 18px; font-weight: 700; }

.modal-close {
  background: transparent;
  border: none;
  color: var(--text3);
  font-size: 20px;
  cursor: pointer;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.modal-close:hover { background: var(--bg2); color: var(--text); }

.modal-body { padding: 28px; }

.modal-footer {
  padding: 20px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ===== GRID LAYOUTS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ===== MISC ===== */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg3);
  color: var(--text2);
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.5s ease;
}

/* ===== ADD TRADE BUTTON (shared across all pages via sidebar) ===== */
.add-trade-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.add-trade-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}

/* ===== IMAGE UPLOAD ===== */
.image-upload-area {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg2);
  position: relative;
}

.image-upload-area:hover,
.image-upload-area.drag-over {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.05);
}

.image-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-icon { font-size: 28px; margin-bottom: 8px; }
.upload-label { font-size: 14px; color: var(--text2); }
.upload-sub { font-size: 12px; color: var(--text3); margin-top: 4px; }

.image-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.image-preview-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-preview-remove {
  position: absolute;
  top: 3px; right: 3px;
  width: 20px; height: 20px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.image-preview-remove:hover { background: var(--red); }

.trade-thumbs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.trade-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform 0.15s;
}

.trade-thumb:hover { transform: scale(1.1); }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.lightbox.open {
  opacity: 1;
  visibility: visible;
}

.lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 10px;
  object-fit: contain;
  box-shadow: 0 32px 80px rgba(0,0,0,0.8);
}

.lightbox-close {
  position: fixed;
  top: 20px; right: 24px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.lightbox-close:hover { background: rgba(255,255,255,0.2); }

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.lightbox-nav:hover { background: rgba(255,255,255,0.2); }
.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

.upload-progress {
  font-size: 12px;
  color: var(--accent);
  margin-top: 8px;
  display: none;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-header, .page-body { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
