:root {
  --bg-main: #0B0F19;
  --bg-sidebar: #111827;
  --bg-card: #1C2433;
  --text-main: #F3F4F6;
  --text-muted: #9CA3AF;
  --border-color: #2D3748;
  
  --primary: #6366F1;
  --primary-hover: #4F46E5;
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, 0.2);
  --danger: #EF4444;
  --danger-bg: rgba(239, 68, 68, 0.2);
  
  --card-radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  overflow-x: hidden;
}

.dashboard {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 40px;
}

.logo-icon {
  color: var(--primary);
  width: 28px;
  height: 28px;
}

.menu-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 12px;
  margin-left: 12px;
  font-weight: 600;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text-muted);
  border-radius: 10px;
  font-weight: 500;
  transition: var(--transition);
}

.nav-item:hover {
  background-color: var(--bg-card);
  color: var(--text-main);
  transform: translateX(4px);
}

.nav-item.active {
  background-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

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

.user-info .name {
  font-size: 14px;
  font-weight: 600;
}

.user-info .role {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Main Content */
.main-content {
  flex-grow: 1;
  padding: 32px 40px;
  height: 100vh;
  overflow-y: auto;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
}

.header-title h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.pulse-indicator {
  width: 10px;
  height: 10px;
  background-color: var(--success);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.subtitle {
  color: var(--text-muted);
  font-size: 15px;
}

.time-filter {
  display: flex;
  background-color: var(--bg-card);
  border-radius: 10px;
  padding: 4px;
  border: 1px solid var(--border-color);
}

.filter-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
}

.filter-btn:hover {
  color: var(--text-main);
}

.filter-btn.active {
  background-color: var(--bg-sidebar);
  color: var(--text-main);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

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

.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: 24px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 4px;
  background: linear-gradient(90deg, var(--primary), #8B5CF6);
  opacity: 0;
  transition: var(--transition);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 500;
  font-size: 14px;
}

.stat-icon {
  background-color: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  padding: 10px;
  border-radius: 10px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 12px;
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
}

.stat-change.positive {
  color: var(--success);
  background-color: var(--success-bg);
}

.stat-change.negative {
  color: var(--danger);
  background-color: var(--danger-bg);
}

.trend-text {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 6px;
  font-weight: 400;
}

/* Charts Section */
.charts-section {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.chart-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: 24px;
}

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

.chart-card h2 {
  font-size: 18px;
  font-weight: 600;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition);
}

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

.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stat-card {
  animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.stats-grid .stat-card:nth-child(1) { animation-delay: 0.1s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 0.15s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.2s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.25s; }
.stats-grid .stat-card:nth-child(5) { animation-delay: 0.3s; }

/* Responsive */
@media (max-width: 1024px) {
  .charts-section {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .dashboard {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 16px;
  }
  .user-profile {
    display: none;
  }
  .nav-menu {
    flex-direction: row;
    overflow-x: auto;
  }
  .menu-label {
    display: none;
  }
  .main-content {
    padding: 20px;
  }
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
}


/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

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

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  width: 90%;
  max-width: 400px;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
  transform: translateY(20px);
  transition: all 0.3s ease;
}

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

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.close-modal-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.3s;
}

.close-modal-btn:hover {
  color: var(--danger);
}

.modal-body {
  padding: 24px;
}

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

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

.form-control {
  background: #111827;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.3s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

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

.btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.3s;
}

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

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: #4F46E5;
}

.edit-btn {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: var(--primary);
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.edit-btn:hover {
  background: var(--primary);
  color: #fff;
}

.flex-row-center {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}


@keyframes spin { 100% { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }
.btn:disabled { opacity: 0.7; cursor: not-allowed; }


/* Table Styles */
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
.data-table th { padding: 16px 24px; color: #9CA3AF; font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.data-table td { padding: 16px 24px; color: #F3F4F6; border-bottom: 1px solid rgba(255, 255, 255, 0.05); transition: all 0.2s; }
.data-table tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
.data-table tbody tr:last-child td { border-bottom: none; }
.site-name-col { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.domain-icon { width: 24px; height: 24px; border-radius: 4px; object-fit: contain; background: #FFF; padding: 2px; }
.pct-badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.pct-positive { background: rgba(16, 185, 129, 0.1); color: #10B981; }
.pct-negative { background: rgba(239, 68, 68, 0.1); color: #EF4444; }
.pct-neutral { background: rgba(107, 114, 128, 0.1); color: #9CA3AF; }


/* Spreadsheet Table Extensions */
.spreadsheet-table th, .spreadsheet-table td { padding: 12px 16px; font-size: 13px; text-align: right; }
.spreadsheet-table th:first-child, .spreadsheet-table td:first-child { text-align: left; }
.spreadsheet-table tfoot td { font-weight: 700; color: #F3F4F6; background: rgba(99, 102, 241, 0.1); border-top: 2px solid rgba(255, 255, 255, 0.1); }
.keyword-input { width: 70px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); color: #F3F4F6; padding: 4px 8px; border-radius: 4px; text-align: right; outline: none; transition: all 0.2s; }
.keyword-input:focus { border-color: #6366F1; background: rgba(0, 0, 0, 0.2); }
.keyword-input::-webkit-inner-spin-button { -webkit-appearance: none; }
