/* ============================================
   PPC ONE DATA DECISION - ULTRA PREMIUM UI
   Enterprise SaaS Dashboard with AI
   ============================================ */

:root {
  --bg: #f0f2f5;
  --bg-subtle: #f7f8fa;
  --card: #ffffff;
  --card-hover: #fafbfc;
  --primary: #c62828;
  --primary-light: rgba(198, 40, 40, 0.08);
  --primary-glow: rgba(198, 40, 40, 0.25);
  --secondary: #1a1d23;
  --accent: #ff7043;
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.08);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.08);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.08);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.08);
  --muted: #6b7280;
  --muted-light: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
  --shadow: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.08);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.1);
  --glass: rgba(255,255,255,0.72);
  --glass-border: rgba(255,255,255,0.3);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --radius-full: 999px;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s ease;
}

/* ===== RESET ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--secondary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* ===== LOADING SCREEN ===== */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #1a1d23 0%, #2d1f1f 50%, #1a1d23 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  width: 320px;
}

.loading-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  margin-bottom: 2.5rem;
}

.loading-icon {
  width: 72px;
  height: 72px;
  animation: loadingSpin 3s linear infinite;
}

.loading-icon svg {
  width: 100%;
  height: 100%;
}

@keyframes loadingSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.loading-brand {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.loading-ppc {
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, #c62828, #ff7043);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 3px;
}

.loading-odd {
  color: rgba(255,255,255,0.5);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.loading-bar-track {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 1rem;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c62828, #ff7043);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.loading-status {
  color: rgba(255,255,255,0.35);
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

/* ===== APP SHELL ===== */
.app-shell {
  display: flex;
  min-height: 100vh;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.app-shell.visible {
  opacity: 1;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--secondary);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo svg {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 1px;
  display: block;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: block;
}

.sidebar-section-label {
  padding: 1.4rem 1.2rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.25);
}

.sidebar-nav {
  padding: 0.5rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.55);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  width: 100%;
  position: relative;
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
}

.sidebar-link.active {
  background: linear-gradient(135deg, rgba(198, 40, 40, 0.3), rgba(255, 112, 67, 0.15));
  color: #fff;
}

.sidebar-link.active svg {
  opacity: 1;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: linear-gradient(180deg, #c62828, #ff7043);
  border-radius: 0 4px 4px 0;
}

.sidebar-badge {
  margin-left: auto;
  background: linear-gradient(135deg, #c62828, #ff7043);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem 0.7rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04);
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  background: linear-gradient(135deg, #c62828, #ff7043);
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 0.78rem;
  font-weight: 600;
  display: block;
  line-height: 1.2;
}

.sidebar-user-role {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.35);
  display: block;
}

.sidebar-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  margin-left: auto;
  flex-shrink: 0;
  box-shadow: 0 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.4); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ===== MAIN WRAPPER ===== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

/* ===== TOPBAR ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-height);
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--primary-light);
  border-radius: var(--radius-xs);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.topbar-breadcrumb svg {
  width: 14px;
  height: 14px;
  color: var(--muted-light);
}

.breadcrumb-section {
  color: var(--muted);
  font-weight: 500;
}

.breadcrumb-page {
  color: var(--secondary);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.topbar-ai-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.9rem;
  background: var(--success-bg);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--success);
}

.ai-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 0.8rem;
  height: 36px;
  min-width: 220px;
}

.topbar-search svg {
  width: 15px;
  height: 15px;
  color: var(--muted-light);
  flex-shrink: 0;
}

.topbar-search input {
  border: none;
  background: transparent;
  font-size: 0.8rem;
  color: var(--secondary);
  outline: none;
  width: 100%;
  font-family: inherit;
}

.topbar-icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.topbar-icon-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--muted-light);
}

.topbar-icon-btn svg {
  width: 17px;
  height: 17px;
  color: var(--muted);
}

.notification-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--card);
}

/* ===== CONTENT ===== */
.content {
  flex: 1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ===== VIEWS ===== */
.view {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
  animation: viewFadeIn 0.4s ease;
}

.view.active {
  display: flex;
}

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== VIEW HEADER ===== */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.view-header h1 {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.view-header p {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.3rem;
  max-width: 520px;
}

.view-header-actions {
  display: flex;
  align-items: flex-end;
  gap: 0.8rem;
  flex-wrap: wrap;
}

/* ===== FILTERS ===== */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-group label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

select {
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--secondary);
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
  min-width: 140px;
}

select:focus {
  border-color: var(--primary);
}

/* ===== BUTTONS ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.2rem;
  background: linear-gradient(135deg, #c62828, #d32f2f);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  box-shadow: 0 4px 12px rgba(198, 40, 40, 0.2);
  white-space: nowrap;
}

.btn-primary svg {
  width: 16px;
  height: 16px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(198, 40, 40, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-glow {
  box-shadow: 0 4px 15px rgba(198, 40, 40, 0.25), 0 0 20px rgba(198, 40, 40, 0.1);
}

.btn-lg {
  padding: 0.7rem 1.6rem;
  font-size: 0.9rem;
}

/* ===== AI INSIGHT BANNER ===== */
.ai-insight-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.2rem;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.06), rgba(198, 40, 40, 0.04));
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: var(--radius);
  animation: bannerSlideIn 0.5s ease;
}

@keyframes bannerSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-insight-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  background: var(--info-bg);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.ai-insight-icon svg {
  width: 18px;
  height: 18px;
  color: var(--info);
}

.ai-insight-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.ai-insight-content strong {
  font-size: 0.82rem;
  font-weight: 700;
}

.ai-insight-content span {
  font-size: 0.72rem;
  color: var(--muted);
}

.ai-insight-badge {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  animation: badgePulse 2.4s infinite;
}

/* ===== KPI GRID ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--card);
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}

.kpi-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #c62828, #ff7043);
  opacity: 0;
  transition: opacity var(--transition);
}

.kpi-card:hover::before {
  opacity: 1;
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  display: grid;
  place-items: center;
  margin-bottom: 0.2rem;
}

.kpi-icon svg {
  width: 18px;
  height: 18px;
}

.kpi-title {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.kpi-footer {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

.kpi-trend {
  font-weight: 700;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.kpi-trend.up {
  color: var(--success);
}

.kpi-trend.down {
  color: var(--danger);
}

.kpi-comparison {
  font-size: 0.68rem;
  color: var(--muted-light);
}

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.2rem;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow);
}

.glass-card {
  background: var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.card-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
}

.card-subtitle {
  font-size: 0.72rem;
  color: var(--muted);
  display: block;
  margin-top: 0.15rem;
}

.card-span-2 {
  grid-column: span 2;
}

/* ===== AI CHIP ===== */
.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(99, 102, 241, 0.08));
  color: #4f46e5;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  animation: chipShimmer 3s infinite;
  flex-shrink: 0;
}

.ai-chip svg {
  width: 8px;
  height: 8px;
  color: #4f46e5;
}

@keyframes chipShimmer {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

/* ===== CARD INSIGHT ===== */
.card-insight {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  background: var(--success-bg);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  color: #065f46;
  border: 1px solid rgba(16, 185, 129, 0.1);
}

.card-insight svg {
  width: 16px;
  height: 16px;
  color: var(--success);
  flex-shrink: 0;
}

/* ===== GRIDS ===== */
.grid-2 {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, 1fr);
}

/* ===== CHART CONTAINER ===== */
.chart-container {
  min-height: 200px;
  background: linear-gradient(135deg, rgba(198, 40, 40, 0.02), rgba(59, 130, 246, 0.02));
  border-radius: var(--radius-sm);
  padding: 1rem 0.5rem 0.5rem;
  display: flex;
  align-items: flex-end;
  position: relative;
}

.chart-container svg {
  width: 100%;
  height: 100%;
}

/* ===== ALERT LIST ===== */
.alert-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.alert-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  transition: background var(--transition-fast);
  border: 1px solid transparent;
}

.alert-item:hover {
  border-color: var(--border);
}

.alert-item.critical {
  background: var(--danger-bg);
}

.alert-item.medium {
  background: var(--warning-bg);
}

.alert-item.ai {
  background: var(--info-bg);
}

.alert-item.success {
  background: var(--success-bg);
}

.alert-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 0.9rem;
}

.alert-item.critical .alert-icon { background: rgba(239, 68, 68, 0.15); }
.alert-item.medium .alert-icon { background: rgba(245, 158, 11, 0.15); }
.alert-item.ai .alert-icon { background: rgba(59, 130, 246, 0.15); }
.alert-item.success .alert-icon { background: rgba(16, 185, 129, 0.15); }

.alert-text {
  flex: 1;
}

.alert-text strong {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 0.1rem;
}

.alert-text span {
  font-size: 0.75rem;
  color: var(--muted);
}

.alert-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.alert-item.critical .alert-badge { background: rgba(239,68,68,0.12); color: #dc2626; }
.alert-item.medium .alert-badge { background: rgba(245,158,11,0.12); color: #d97706; }
.alert-item.ai .alert-badge { background: rgba(59,130,246,0.12); color: #2563eb; }
.alert-item.success .alert-badge { background: rgba(16,185,129,0.12); color: #059669; }

/* ===== RANK LIST ===== */
.rank-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.rank-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.rank-item:hover {
  background: var(--bg-subtle);
}

.rank-position {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  flex-shrink: 0;
}

.rank-position.gold { background: #fef3c7; color: #92400e; }
.rank-position.silver { background: #f3f4f6; color: #374151; }
.rank-position.bronze { background: #fed7aa; color: #9a3412; }

.rank-info {
  flex: 1;
}

.rank-info strong {
  font-size: 0.82rem;
  display: block;
  line-height: 1.3;
}

.rank-info span {
  font-size: 0.68rem;
  color: var(--muted);
}

.rank-score {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--primary);
}

/* ===== DONUT GRID ===== */
.donut-grid {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.donut-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.donut-item svg {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
}

.donut-info strong {
  display: block;
  font-size: 0.82rem;
}

.donut-info span {
  font-size: 0.68rem;
  color: var(--muted);
}

/* ===== REGIONAL BARS ===== */
.regional-bars {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.regional-bar-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.regional-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
}

.regional-bar-header strong {
  font-weight: 600;
}

.regional-bar-header span {
  font-weight: 700;
  color: var(--info);
}

.regional-bar-track {
  height: 6px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.regional-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  animation: barGrow 1s ease forwards;
}

@keyframes barGrow {
  from { width: 0 !important; }
}

/* ===== METRIC STACK ===== */
.metric-stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.metric-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
}

.metric-header span {
  color: var(--muted);
  font-weight: 500;
}

.metric-header strong {
  font-weight: 800;
  font-size: 0.85rem;
}

.metric-bar {
  height: 8px;
  background: rgba(198, 40, 40, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #c62828, #ff7043);
  border-radius: var(--radius-full);
  animation: barGrow 1.5s ease;
}

/* ===== RECOMMENDATIONS ===== */
.recommendations-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.recommendation-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  border: 1px solid rgba(245, 158, 11, 0.08);
  font-size: 0.78rem;
  line-height: 1.5;
}

.recommendation-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(245, 158, 11, 0.2);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 0.65rem;
  margin-top: 0.1rem;
}

/* ===== BEHAVIOR GRID ===== */
.behavior-grid {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.behavior-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.behavior-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
}

.behavior-header span {
  color: var(--muted);
}

.behavior-bar {
  height: 6px;
  background: rgba(16, 185, 129, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.behavior-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  border-radius: var(--radius-full);
  animation: barGrow 1.8s ease;
}

/* ===== AI MODEL STATUS ===== */
.ai-model-status {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
}

.ai-model-card {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 1rem;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.ai-model-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-light);
  flex-shrink: 0;
}

.ai-model-indicator.active {
  background: var(--success);
  animation: pulse 2s infinite;
}

.ai-model-label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: block;
}

.ai-model-card strong {
  font-size: 0.82rem;
  display: block;
}

/* ===== SIMULATION ===== */
.simulation-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.slider-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-header label {
  font-size: 0.82rem;
  font-weight: 600;
}

.slider-value {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-full);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c62828, #ff7043);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(198, 40, 40, 0.3);
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c62828, #ff7043);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(198, 40, 40, 0.3);
}

.simulation-presets {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

.preset-label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

.preset-btn {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  color: var(--secondary);
}

.preset-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.sim-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
}

.sim-kpi {
  padding: 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  text-align: center;
  transition: all var(--transition);
}

.sim-kpi-title {
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: block;
  margin-bottom: 0.3rem;
}

.sim-kpi-value {
  font-size: 1.3rem;
  font-weight: 800;
  display: block;
}

.sim-kpi-trend {
  font-size: 0.68rem;
  color: var(--success);
  font-weight: 600;
  display: block;
  margin-top: 0.2rem;
}

/* ===== DATA FLOW ===== */
.data-flow-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 2rem 1.5rem;
  background: linear-gradient(135deg, rgba(198, 40, 40, 0.02), rgba(59, 130, 246, 0.02));
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.flow-endpoint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1.2rem 1.5rem;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
  min-width: 140px;
  transition: transform var(--transition);
}

.flow-endpoint:hover {
  transform: translateY(-3px);
}

.flow-endpoint.highlighted {
  background: linear-gradient(135deg, rgba(198, 40, 40, 0.06), rgba(255, 112, 67, 0.04));
  border-color: rgba(198, 40, 40, 0.2);
  box-shadow: 0 8px 30px rgba(198, 40, 40, 0.1);
}

.flow-endpoint-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: grid;
  place-items: center;
}

.flow-endpoint-icon svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.flow-endpoint strong {
  font-size: 0.9rem;
}

.flow-endpoint span {
  font-size: 0.68rem;
  color: var(--muted);
}

.flow-status {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.flow-status.online {
  background: var(--success-bg);
  color: var(--success);
}

.flow-status.processing {
  background: var(--warning-bg);
  color: var(--warning);
  animation: badgePulse 1.5s infinite;
}

.flow-connector-line {
  flex: 1;
  max-width: 160px;
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
  position: relative;
  margin: 0 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.flow-particle {
  position: absolute;
  top: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c62828, #ff7043);
  animation: flowParticle 2s infinite ease-in-out;
  box-shadow: 0 0 6px rgba(198, 40, 40, 0.4);
}

.flow-particle.delay-1 { animation-delay: 0.6s; }
.flow-particle.delay-2 { animation-delay: 1.2s; }

@keyframes flowParticle {
  0% { left: -4px; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { left: calc(100% - 4px); opacity: 0; }
}

.flow-speed {
  position: absolute;
  top: 16px;
  font-size: 0.62rem;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 500;
}

/* ===== SYNC GRID ===== */
.sync-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.sync-card {
  padding: 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.sync-card .sync-label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}

.sync-card .sync-value {
  font-size: 1.1rem;
  font-weight: 800;
}

.sync-card .sync-detail {
  font-size: 0.68rem;
  color: var(--success);
  font-weight: 600;
}

/* ===== TABLES ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.table-wrapper th {
  padding: 0.7rem 0.9rem;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table-wrapper td {
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.table-wrapper tr:hover td {
  background: var(--bg-subtle);
}

.table-wrapper tr:last-child td {
  border-bottom: none;
}

.status-badge {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-badge.synced { background: var(--success-bg); color: var(--success); }
.status-badge.adjusting { background: var(--warning-bg); color: var(--warning); }
.status-badge.alert { background: var(--danger-bg); color: var(--danger); }

.balance-positive { color: var(--success); font-weight: 700; }
.balance-negative { color: var(--danger); font-weight: 700; }

/* ===== ERP METRICS ===== */
.erp-metrics {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.erp-metric-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-light);
}

.erp-metric-item:last-child {
  border-bottom: none;
}

.erp-metric-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.erp-metric-info {
  flex: 1;
}

.erp-metric-info span {
  font-size: 0.75rem;
  color: var(--muted);
}

.erp-metric-value {
  font-weight: 800;
  font-size: 0.85rem;
}

/* ===== VENTAS ITEMS ===== */
.ventas-product-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.ventas-product-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.ventas-product-item:hover {
  background: var(--bg-subtle);
}

.ventas-product-rank {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--muted-light);
  width: 20px;
}

.ventas-product-info {
  flex: 1;
}

.ventas-product-info strong {
  font-size: 0.82rem;
  display: block;
}

.ventas-product-info span {
  font-size: 0.68rem;
  color: var(--muted);
}

.ventas-product-value {
  font-weight: 800;
  font-size: 0.9rem;
}

.ventas-product-trend {
  font-size: 0.68rem;
  font-weight: 700;
}

/* ===== PRODUCCION ===== */
.production-line-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.production-line-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.production-line-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.production-line-name {
  font-size: 0.82rem;
  font-weight: 600;
}

.production-line-efficiency {
  font-size: 0.85rem;
  font-weight: 800;
}

.production-line-bar {
  height: 8px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.production-line-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.8s ease;
}

.production-line-fill.high { background: linear-gradient(90deg, #10b981, #34d399); }
.production-line-fill.medium { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.production-line-fill.low { background: linear-gradient(90deg, #ef4444, #f87171); }

.production-line-detail {
  font-size: 0.68rem;
  color: var(--muted);
}

/* ===== INVENTARIO CATEGORIES ===== */
.inventory-category-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.inventory-category-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.inventory-category-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.inventory-category-info {
  flex: 1;
}

.inventory-category-info strong {
  font-size: 0.82rem;
  display: block;
}

.inventory-category-bar {
  height: 5px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  margin-top: 0.3rem;
  overflow: hidden;
}

.inventory-category-fill {
  height: 100%;
  border-radius: var(--radius-full);
  animation: barGrow 1.2s ease;
}

.inventory-category-value {
  font-weight: 800;
  font-size: 0.85rem;
  text-align: right;
  min-width: 40px;
}

/* ===== REPORTES ===== */
.report-card {
  padding: 1.2rem;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
}

.report-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.report-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
}

.report-card-icon svg {
  width: 20px;
  height: 20px;
}

.report-card h4 {
  font-size: 0.9rem;
  font-weight: 700;
}

.report-card p {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
}

.report-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-light);
}

.report-card-footer span {
  font-size: 0.68rem;
  color: var(--muted);
}

.report-card-footer .report-btn {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ===== CONFIG PANELS ===== */
.config-panel {
  padding: 1.2rem;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.config-panel h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.config-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border-light);
}

.config-item:last-child {
  border-bottom: none;
}

.config-item-label {
  font-size: 0.82rem;
  font-weight: 500;
}

.config-item-value {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
}

.config-toggle {
  width: 36px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--border);
  position: relative;
  cursor: pointer;
  border: none;
  transition: background var(--transition-fast);
}

.config-toggle.on {
  background: var(--success);
}

.config-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.config-toggle.on::after {
  transform: translateX(16px);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  .ai-model-status {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 960px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .main-wrapper {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: flex;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .card-span-2 {
    grid-column: span 1;
  }

  .simulation-layout {
    grid-template-columns: 1fr;
  }

  .data-flow-container {
    flex-direction: column;
    gap: 0.5rem;
  }

  .flow-connector-line {
    width: 4px;
    height: 40px;
    max-width: none;
    margin: 0;
  }

  .flow-particle {
    animation: flowParticleVertical 2s infinite ease-in-out;
  }

  .flow-speed {
    top: auto;
    left: 20px;
  }

  .topbar-search {
    display: none;
  }

  .topbar-ai-status span {
    display: none;
  }
}

@keyframes flowParticleVertical {
  0% { top: -4px; opacity: 0; left: -2px; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: calc(100% - 4px); opacity: 0; left: -2px; }
}

@media (max-width: 640px) {
  .content {
    padding: 1rem;
  }

  .grid-3 {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .view-header {
    flex-direction: column;
  }

  .view-header h1 {
    font-size: 1.3rem;
  }

  .sim-kpi-grid {
    grid-template-columns: 1fr;
  }

  .sync-grid {
    grid-template-columns: 1fr;
  }

  .ai-model-status {
    grid-template-columns: 1fr;
  }

  .ai-insight-banner {
    flex-direction: column;
    text-align: center;
  }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted-light);
}

/* ===== SELECTION ===== */
::selection {
  background: rgba(198, 40, 40, 0.15);
  color: var(--secondary);
}
