/* Vision Profit — Design System */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy: #0D1117;
  --navy2: #161B27;
  --violet: #7C3AED;
  --violet-light: #A78BFA;
  --violet-dim: rgba(124,58,237,0.12);
  --lime: #84CC16;
  --lime-dim: rgba(132,204,22,0.1);
  --rose: #F43F5E;
  --rose-dim: rgba(244,63,94,0.08);
  --amber: #F59E0B;
  --amber-dim: rgba(245,158,11,0.08);
  --yellow: #FACC15;
  --yellow-dim: rgba(250,204,21,0.08);
  --orange: #F97316;
  --orange-dim: rgba(249,115,22,0.08);
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #475569;
  --border: rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.13);
  --surface: #161B27;
  --surface2: #1E2535;
  --surface3: #252D3D;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-soft: 0 12px 40px rgba(0,0,0,0.22);
  --shadow-card: 0 16px 50px rgba(0,0,0,0.28);
}

html { height: 100%; }
body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(124,58,237,0.18), transparent 34%),
    radial-gradient(circle at top right, rgba(132,204,22,0.08), transparent 28%),
    linear-gradient(180deg, #0b0f16 0%, #0d1117 45%, #090c12 100%);
  color: var(--text-primary);
  height: 100%;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  overflow: hidden;
}

body::before,
body::after {
  content: '';
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
  filter: blur(64px);
  opacity: 0.55;
}

body::before {
  top: -120px;
  right: -90px;
  width: 280px;
  height: 280px;
  background: rgba(124,58,237,0.24);
}

body::after {
  bottom: -120px;
  left: -100px;
  width: 320px;
  height: 320px;
  background: rgba(132,204,22,0.12);
}

/* ── LAYOUT ── */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: rgba(13,17,23,0.84);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow-y: auto;
  backdrop-filter: blur(18px);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 22px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--violet);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.logo-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.logo-name,
.topbar-title,
.page-title,
.metric-value,
.card-title,
.modal-title,
.result-price {
  font-family: 'Space Grotesk', 'Manrope', sans-serif;
}
.logo-name span { color: var(--violet-light); }
.logo-tagline { font-size: 11px; color: var(--text-muted); }
.sidebar-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 18px 20px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
  border-radius: 0 999px 999px 0;
}
.nav-item:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.nav-item.active {
  color: var(--violet-light);
  background: var(--violet-dim);
  border-left-color: var(--violet);
}
.nav-item i { font-size: 16px; width: 18px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}
.badge-rose { background: rgba(244,63,94,0.2); color: var(--rose); }
.badge-amber { background: rgba(245,158,11,0.2); color: var(--amber); }
.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.store-connected {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  background: var(--lime-dim);
  border: 1px solid rgba(132,204,22,0.25);
  border-radius: var(--radius-md);
}
.store-disconnected {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  background: var(--rose-dim);
  border: 1px solid rgba(244,63,94,0.25);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
}
.store-disconnected:hover { background: rgba(244,63,94,0.14); }
.store-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-green { background: var(--lime); }
.dot-red { background: var(--rose); }
.store-label { font-size: 12px; font-weight: 500; }
.store-label.green { color: var(--lime); }
.store-label.red { color: var(--rose); }
.store-sub { font-size: 11px; color: var(--text-muted); }

/* ── MAIN ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.topbar {
  background: rgba(13,17,23,0.8);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-title { font-size: 15px; font-weight: 600; flex: 1; }
.topbar-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.period-group { display: flex; gap: 3px; }
.period-btn {
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.period-btn:hover { background: var(--surface2); color: var(--text-primary); }
.period-btn.active { background: var(--violet); color: #fff; border-color: var(--violet); }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  font-family: inherit;
}
.btn-primary { background: var(--violet); color: #fff; }
.btn-primary:hover { background: #6D28D9; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text-primary); }
.btn-danger { background: rgba(244,63,94,0.15); color: var(--rose); border: 1px solid rgba(244,63,94,0.3); }
.btn-danger:hover { background: rgba(244,63,94,0.25); }
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  scroll-behavior: smooth;
}

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.card:hover {
  border-color: rgba(255,255,255,0.12);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}
.card-sm { padding: 14px 16px; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.card-link { font-size: 12px; color: var(--violet-light); cursor: pointer; text-decoration: none; }
.card-link:hover { text-decoration: underline; }

/* ── METRIC CARDS ── */
.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.12);
  box-shadow: var(--shadow-card);
}
.metric-accent {
  position: absolute;
  top: 0; right: 0;
  width: 3px;
  height: 100%;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}
.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.metric-value { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.metric-delta { font-size: 11px; margin-top: 5px; color: var(--text-muted); }
.delta-up { color: var(--lime); }
.delta-down { color: var(--rose); }

/* ── GRID LAYOUTS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.chart-card { display: flex; flex-direction: column; }
.chart-card .card-header { margin-bottom: 12px; }
.chart-wrap {
  position: relative;
  height: 250px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
}
.chart-wrap.tall { height: 300px; }
.chart-empty {
  height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.chart-empty .empty-state { padding: 0; }
.chart-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
}

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  font-family: 'Space Grotesk', 'Manrope', sans-serif;
}
tbody td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }

/* ── BADGES / PILLS ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.badge-green { background: rgba(132,204,22,0.15); color: #A3E635; }
.badge-red { background: rgba(244,63,94,0.15); color: #FB7185; }
.badge-amber { background: rgba(245,158,11,0.15); color: #FCD34D; }
.badge-violet { background: rgba(124,58,237,0.15); color: var(--violet-light); }
.badge-gray { background: rgba(148,163,184,0.12); color: var(--text-secondary); }

/* ── ALERTS ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  border: 1px solid transparent;
  box-shadow: 0 10px 24px rgba(0,0,0,0.12);
}
.alert:last-child { margin-bottom: 0; }
.alert-danger { background: var(--rose-dim); border-color: rgba(244,63,94,0.2); }
.alert-warn { background: var(--amber-dim); border-color: rgba(245,158,11,0.2); }
.alert-info { background: var(--violet-dim); border-color: rgba(124,58,237,0.2); }
.alert-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.alert-danger .alert-icon { color: var(--rose); }
.alert-warn .alert-icon { color: var(--amber); }
.alert-info .alert-icon { color: var(--violet-light); }
.alert-text { font-size: 12px; line-height: 1.5; color: var(--text-secondary); }
.alert-text strong { color: var(--text-primary); font-weight: 500; }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.form-input, .form-select {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus { border-color: var(--violet); box-shadow: 0 0 0 2px rgba(124,58,237,0.15); }
.form-select { appearance: none; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── EMPTY STATE ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}
.empty-icon { font-size: 48px; color: var(--text-muted); margin-bottom: 16px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.empty-desc { font-size: 13px; color: var(--text-muted); max-width: 320px; line-height: 1.6; margin-bottom: 20px; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,8,13,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(10px);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-card);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; padding: 2px; }
.modal-close:hover { color: var(--text-primary); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── TABS ── */
.tab-nav { display: flex; gap: 2px; background: var(--surface2); padding: 3px; border-radius: var(--radius-md); margin-bottom: 20px; width: fit-content; }
.tab-btn {
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 500;
  border: 1px solid var(--border);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── MISC ── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.text-green { color: var(--lime); }
.text-red { color: var(--rose); }
.text-amber { color: var(--amber); }
.text-yellow { color: var(--yellow); }
.text-orange { color: var(--orange); }
.text-violet { color: var(--violet-light); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-semibold { font-weight: 600; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.ml-auto { margin-left: auto; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.mt-4 { margin-top: 16px; }
.page-header { margin-bottom: 22px; }
.page-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.page-desc { font-size: 13px; color: var(--text-muted); }

/* ── PROGRESS BAR ── */
.progress-bar { height: 4px; background: var(--surface3); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.progress-fill { height: 100%; border-radius: 2px; background: var(--violet); }

/* ── TOAST ── */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border-hover);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 9px;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.25s ease;
  max-width: 320px;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.toast-success { border-color: rgba(132,204,22,0.4); }
#toast.toast-error { border-color: rgba(244,63,94,0.4); }

/* ── CONNECT BANNER ── */
.connect-banner {
  background:
    radial-gradient(circle at top left, rgba(124,58,237,0.16), transparent 38%),
    radial-gradient(circle at bottom right, rgba(132,204,22,0.10), transparent 34%),
    linear-gradient(135deg, rgba(14,18,28,0.92), rgba(18,24,36,0.98));
  border: 1px solid rgba(124,58,237,0.24);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  text-align: center;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.connect-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255,255,255,0.03), transparent 45%, rgba(255,255,255,0.02));
  pointer-events: none;
}
.connect-banner > * { position: relative; z-index: 1; }
.connect-banner-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  font-size: 24px;
  color: var(--violet-light);
  background: rgba(124,58,237,0.14);
  border: 1px solid rgba(124,58,237,0.22);
}
.connect-banner-title { font-size: 18px; font-weight: 800; margin-bottom: 8px; letter-spacing: -0.03em; }
.connect-banner-desc { font-size: 13px; color: var(--text-secondary); max-width: 520px; margin: 0 auto 18px; line-height: 1.65; }
.connect-banner-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.connect-banner-actions .btn {
  min-width: 148px;
}

.connect-chooser {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.connect-choice {
  padding: 16px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  text-align: left;
}
.connect-choice:hover {
  transform: translateY(-1px);
  border-color: rgba(124,58,237,0.28);
}
.connect-choice.active {
  background: linear-gradient(180deg, rgba(124,58,237,0.18), rgba(124,58,237,0.08));
  border-color: rgba(124,58,237,0.45);
  box-shadow: 0 12px 28px rgba(124,58,237,0.12);
}
.connect-choice-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.connect-choice-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
}
.connect-choice-name { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.connect-choice-meta { font-size: 12px; color: var(--text-secondary); line-height: 1.45; }

/* ── CHART BARS ── */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 130px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.bar-stack { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.bar-seg { width: 100%; border-radius: 3px 3px 0 0; min-height: 3px; }
.bar-lbl { font-size: 10px; color: var(--text-muted); }
.chart-legend { display: flex; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.legend-dot-sq { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }

/* ── CALC RESULT BOX ── */
.calc-result {
  background: var(--surface2);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  box-shadow: var(--shadow-soft);
}
.result-price { font-size: 30px; font-weight: 700; color: var(--violet-light); letter-spacing: -1px; }

.page.active {
  animation: fadeInUp 0.22s ease both;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 10px; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .sidebar { width: 60px; backdrop-filter: blur(10px); }
  .sidebar .logo-name, .sidebar .logo-tagline, .sidebar-section, .nav-item span,
  .sidebar-footer .store-label, .sidebar-footer .store-sub { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .nav-item i { width: auto; }
  .content { padding: 18px 16px 22px; }
  .topbar { padding: 0 16px; }
  .connect-banner { padding: 22px 18px; }
  .connect-banner-actions { flex-direction: column; align-items: stretch; }
  .connect-banner-actions .btn { width: 100%; min-width: 0; }
  .connect-chooser { grid-template-columns: 1fr; }
  .connect-choice { padding: 14px; }
  .calc-result { flex-direction: column; align-items: flex-start; gap: 14px; }
}
