:root {
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --primary-light: rgba(139, 92, 246, 0.15);
  
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.15);
  --info: #3b82f6;

  /* Dark mode default base */
  --bg-dark: #0f1115;
  --bg-surface: #1a1d24;
  --bg-surface-hover: #232730;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --border: rgba(255, 255, 255, 0.08);

  --font-family: 'Outfit', sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.15);
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  overflow: hidden; /* App-like feel */
  -webkit-font-smoothing: antialiased;
}

/* App Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  z-index: 10;
}

.sidebar-header {
  height: 80px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.logo i {
  font-size: 1.75rem;
}

.nav-menu {
  flex: 1;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.nav-item i {
  font-size: 1.25rem;
  transition: var(--transition);
}

.nav-item:hover {
  color: var(--text-main);
  background: var(--bg-surface-hover);
}

.nav-item.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 60%;
  width: 4px;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
}

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

.currency-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-dark);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.currency-selector select {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: inherit;
  outline: none;
  cursor: pointer;
  width: 100%;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0; 
  background: radial-gradient(circle at top right, rgba(139, 92, 246, 0.05), transparent 400px);
}

.top-header {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(26, 29, 36, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 5;
}

#page-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 1.25rem;
}

.icon-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  cursor: pointer;
}

.content-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  position: relative;
}

/* Views */
.view-section {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.view-section.active {
  display: block;
}

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

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

/* Components */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  outline: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px 0 rgba(139, 92, 246, 0.39);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
}

/* Grid & Layouts */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
  border-color: rgba(139, 92, 246, 0.3);
}

.kpi-title {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
}

.kpi-trend {
  margin-top: 8px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

/* Tables */
.table-container {
  padding: 0;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 16px 24px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
}

.data-table td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  vertical-align: middle;
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background: var(--bg-surface-hover);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-testing { background: var(--warning-light); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-scaling { background: var(--success-light); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-killed { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-research { background: var(--primary-light); color: var(--primary);  border: 1px solid rgba(139, 92, 246, 0.2); }
.badge-paused { background: rgba(156, 163, 175, 0.15); color: var(--text-muted); border: 1px solid rgba(156, 163, 175, 0.2); }

/* HitRate Tracker Layout */
.hitrate-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.hitrate-main { flex: 2; }
.hitrate-side { flex: 1; }

.pipeline-stages {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.pipeline-stage {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(0,0,0,0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pipeline-stage h3 { font-size: 1.1rem; }
.stage-stats { display: flex; gap: 20px; }
.stage-stat-item { text-align: right; }
.stage-stat-label { font-size: 0.8rem; color: var(--text-muted); }
.stage-stat-val { font-size: 1.2rem; font-weight: 600; }

.category-bar-container {
  margin-top: 16px;
}
.cat-bar-wrap {
  margin-bottom: 12px;
}
.cat-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 4px;
}
.cat-progress {
  height: 8px;
  background: var(--bg-dark);
  border-radius: 4px;
  overflow: hidden;
}
.cat-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.modal-overlay.active {
  display: block;
  opacity: 1;
}

.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  z-index: 101;
  display: none;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  max-height: 90vh;
  display: none;
  flex-direction: column;
}

.modal.active {
  display: flex;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

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

.modal-header h3 { font-size: 1.25rem; font-weight: 600; }
.close-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.25rem; }
.close-btn:hover { color: var(--text-main); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group.full-width { grid-column: span 2; }

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.form-group input, 
.form-group select, 
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.links-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-actions {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Competitor Grid */
.grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}
.competitor-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: var(--transition);
}
.competitor-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

/* Utilities */
.mt-4 { margin-top: 24px; }
.mb-2 { margin-bottom: 12px; }

/* Scrum / Kanban Board */
.kanban-board {
  display: flex;
  gap: 24px;
  overflow-x: auto;
  padding-bottom: 24px;
  min-height: 400px;
}
.kanban-col {
  flex: 1;
  min-width: 300px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.kanban-col h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kanban-dropzone {
  flex: 1;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.kanban-dropzone.drag-over {
  background: rgba(139, 92, 246, 0.05);
  border-radius: var(--radius-md);
  border: 1px dashed var(--primary);
}
.kanban-card {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: grab;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.kanban-card:active {
  cursor: grabbing;
}
.kanban-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* Dashboard Widget Layout Default */
.dashboard-widgets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

/* Mobile Toggle Button */
.mobile-menu-toggle {
  display: none;
}

/* ---------------------- CSS Responsiveness ---------------------- */
@media (max-width: 900px) {
  /* Hitrate layout breaks to column */
  .hitrate-layout {
    flex-direction: column;
  }
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }

  /* Make sidebar slide-in instead of fixed layout */
  .sidebar {
    position: fixed;
    left: -260px; /* Hidden offscreen by default */
    top: 0;
    bottom: 0;
    box-shadow: var(--shadow-md);
  }
  
  .sidebar.open {
    left: 0;
  }

  .top-header {
    padding: 0 16px;
    height: 70px;
  }
  
  #page-title {
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions {
    gap: 8px;
  }

  .content-scroll-area {
    padding: 16px;
  }

  .dashboard-widgets {
    grid-template-columns: 1fr;
  }
  
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Shrink store selector */
  #store-selector {
    max-width: 100px;
    text-overflow: ellipsis;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-group.full-width {
    grid-column: span 1;
  }

  /* Modals */
  .modal {
    width: 95%;
    padding: 0;
  }
  
  .modal-body {
    padding: 16px;
  }
  
  /* Buttons on mobile */
  .btn {
    padding: 8px 12px;
    font-size: 0.9rem;
  }
  
  /* Competitor and Ad spy panes */
  div[style*="display:flex; gap:20px; flex-wrap:wrap;"] {
    flex-direction: column;
  }
}
