/* =========================================
   Insight AI - Layout & Components
   ========================================= */

/* App Shell */
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  position: relative;
  width: var(--sidebar-width);
  background: var(--color-navy);
  color: white;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.1);
  transition: width 0.3s ease;
  z-index: 20;
}

.brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: linear-gradient(90deg, var(--color-navy) 0%, var(--color-navy-light) 100%);
}

.brand span { color: var(--color-white); }
.brand .highlight { color: var(--color-pink); }
.brand-text { display: inline-flex; align-items: center; }
.brand-logo-img {
  height: 45px;
  width: auto;
  filter: drop-shadow(0 0 10px rgba(242, 22, 81, 0.5));
}

.nav-menu {
  flex: 1;
  padding: 1.5rem 1rem;
  overflow-y: auto;
}

.nav-category {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b7280;
  font-weight: 700;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  padding-left: 0.75rem;
}

.nav-category:first-child {
  margin-top: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.25rem;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.7);
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s;
  text-decoration: none;
  border: none;
  background: transparent;
  width: 100%;
  cursor: pointer;
  text-align: left;
}

.nav-item.logout-btn {
  margin-top: 1rem;
  color: #EF4444;
  background: rgba(239, 68, 68, 0.1);
  justify-content: center;
}
.nav-item.logout-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #F87171;
}

.sidebar-footer {
  padding: 1.5rem 1rem;
  background: #0f172a; /* Darker navy */
  border-top: 1px solid rgba(255,255,255,0.05);
}

.footer-info {
  margin-bottom: 0.5rem;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: white;
}

.nav-item.active {
  background: var(--color-pink);
  color: white;
  box-shadow: var(--shadow-neon);
}

.nav-icon { margin-right: 0.75rem; width: 20px; text-align: center; }

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-gray-50);
  position: relative;
  overflow: hidden;
}

/* Top Header / Time Travel Bar */
.top-bar {
  height: auto;
  min-height: var(--header-height);
  background: white;
  border-bottom: 1px solid var(--color-gray-200);
  display: flex;
  align-items: center;
  padding: 0.75rem 2rem;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  z-index: 10;
  gap: 1rem;
  flex-wrap: wrap;
}

.time-travel {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: linear-gradient(135deg, #ffffff 0%, #f6f8fb 100%);
  padding: 0.6rem 0.9rem;
  border-radius: 16px;
  border: 1px solid var(--color-gray-200);
  box-shadow: 0 6px 14px rgba(2, 24, 61, 0.08);
  min-width: 0;
  max-width: 100%;
}

.time-travel-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--color-gray-800);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.time-travel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.time-travel-date {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--color-navy);
}

.time-travel-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.time-granularity {
  display: inline-flex;
  background: var(--color-gray-100);
  padding: 0.25rem;
  border-radius: 999px;
  border: 1px solid var(--color-gray-200);
  gap: 0.25rem;
  flex-wrap: wrap;
}

.gran-btn {
  border: none;
  background: transparent;
  color: #4B5563;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.gran-btn:hover {
  color: var(--color-navy);
  background: rgba(2, 24, 61, 0.06);
}

.gran-btn.active {
  background: var(--color-navy);
  color: white;
  box-shadow: 0 4px 10px rgba(2, 24, 61, 0.2);
}

.time-nav {
  display: inline-flex;
  gap: 0.5rem;
}

.time-nav-btn {
  border: 1px solid var(--color-gray-200);
  background: white;
  color: var(--color-navy);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.time-nav-btn:hover {
  border-color: var(--color-navy);
  box-shadow: 0 4px 10px rgba(2, 24, 61, 0.12);
  transform: translateY(-1px);
}

.time-nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.view-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  scroll-behavior: smooth;
}

/* Components: KPI Card */
.kpi-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
  /* overflow: hidden; Removed to allow tooltips */
  transition: transform 0.2s;
  border: 1px solid rgba(0,0,0,0.02);
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px;
  background: var(--color-gray-200);
  border-top-left-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-lg);
}
.kpi-card.variant-pink::before { background: var(--color-pink); }
.kpi-card.variant-warning::before { background: var(--color-warning); }
.kpi-card.variant-success::before { background: var(--color-success); }
.kpi-card.variant-navy::before { background: var(--color-navy); }

.kpi-title { font-size: 0.875rem; color: #6B7280; font-weight: 500; margin-bottom: 0.5rem; }
.kpi-value { font-size: 2rem; font-weight: 800; color: var(--color-navy); line-height: 1; }
.kpi-trend { font-size: 0.875rem; margin-top: 0.5rem; display: flex; align-items: center; }

/* Components: Charts & Tables */
.panel {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.panel-title { font-size: 1.125rem; font-weight: 700; color: var(--color-navy); }

/* Table Styles */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #6B7280;
  background: var(--color-gray-50);
  border-bottom: 1px solid var(--color-gray-200);
}
.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-gray-100);
  font-size: 0.875rem;
}
.data-table tr:hover { background-color: var(--color-gray-50); }

/* Components: Buttons & Toggles */
.btn-primary {
  background: var(--color-navy);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--color-navy);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn-primary:hover {
  background: var(--color-navy-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.btn-outline {
  background: transparent;
  color: var(--color-navy);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--color-gray-200);
  cursor: pointer;
}
.btn-outline:hover {
  background: white;
  border-color: var(--color-navy);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px -1px rgba(0,0,0,0.05);
}

.toggle-group {
  display: inline-flex;
  background: var(--color-gray-100);
  padding: 0.25rem;
  border-radius: var(--radius-lg);
  gap: 0.25rem;
  border: 1px solid var(--color-gray-200);
}

.btn-toggle {
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  color: #6B7280;
  background: transparent;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
}

.btn-toggle:hover {
  color: var(--color-navy);
  background: rgba(255,255,255,0.5);
}

.btn-toggle.active {
  background: white;
  color: var(--color-navy);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Loader */
.skeleton {
  background: #E5E7EB;
  border-radius: 4px;
  animation: pulse 1.5s infinite ease-in-out;
}
@keyframes pulse { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }

/* PDF Print Mode */
@media print {
  .sidebar, .top-bar, .no-print { display: none !important; }
  .main-wrapper { background: white; height: auto; overflow: visible; }
  .view-content { padding: 0; }
  .panel { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}

/* Utility for tables (used in JS views) */
.overflow-x-auto {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  display: block;
}

/* =========================================
   AI Chat Widget
   ========================================= */

/* Sidebar expansion when chat is active */
.sidebar.chat-active {
  width: 400px;
}

.sidebar.chat-active + .main-wrapper {
  /* El main-wrapper se adapta automáticamente por flexbox */
  flex: 1;
}

/* Chat Widget Container */
.ai-chat-widget {
  margin: 0.5rem 0.75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;
  transition: all 0.3s ease;
}

.ai-chat-widget.expanded {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--color-pink);
  box-shadow: 0 0 20px rgba(242, 22, 81, 0.2);
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.chat-icon {
  font-size: 1.2rem;
}

.chat-title {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

.chat-expand-icon {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
  transition: transform 0.3s;
}

.ai-chat-widget.expanded .chat-expand-icon {
  transform: rotate(180deg);
}

/* Chat Body */
.chat-body {
  display: none;
  flex-direction: column;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-chat-widget.expanded .chat-body {
  display: flex;
}

/* Chat Messages Area */
.chat-messages {
  height: 200px;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
}

/* Custom scrollbar for chat */
.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

/* Chat Message Bubbles */
.chat-message {
  max-width: 90%;
  animation: fadeInUp 0.3s ease;
}

.chat-message.user {
  align-self: flex-end;
}

.chat-message.assistant {
  align-self: flex-start;
}

.chat-message .message-content {
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  font-size: 0.8rem;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-message.user .message-content {
  background: var(--color-pink);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant .message-content {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.95);
  border-bottom-left-radius: 4px;
}

.chat-message.error .message-content {
  background: rgba(239, 68, 68, 0.3);
  border: 1px solid rgba(239, 68, 68, 0.5);
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  align-items: center;
}

.typing-indicator .dots {
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0.3; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Chat Input Area */
.chat-input-area {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  color: white;
  font-size: 0.85rem;
  outline: none;
  transition: all 0.2s;
}

.chat-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.chat-input:focus {
  border-color: var(--color-pink);
  background: rgba(255, 255, 255, 0.15);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--color-pink);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.chat-send-btn:hover {
  background: #d4124a;
  transform: scale(1.05);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* =========================================
   Utility Classes (Tailwind-like)
   ========================================= */

/* Components: Insight Cards */
.insight-card {
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  background: white;
  border: 1px solid rgba(0,0,0,0.05);
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  transition: all 0.2s ease;
  margin-bottom: 1rem; /* Better separation */
  position: relative;
  overflow: hidden; /* For accent strip */
}

.insight-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.1);
}

.insight-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: white;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.insight-content {
  flex: 1;
}

.insight-title {
  font-size: 1.1rem;
  font-weight: 800; /* Bolder */
  color: var(--color-navy);
  margin-bottom: 0.5rem;
  display: block;
  letter-spacing: -0.01em;
}

.insight-body {
  font-size: 1rem;
  color: #4B5563;
  line-height: 1.6;
}

/* Variant Accents with Background Tints */
.insight-card.success {
  background: linear-gradient(to right, rgba(46, 204, 113, 0.05), rgba(46, 204, 113, 0.01));
  border-left: 5px solid var(--color-success);
}
.insight-card.success .insight-icon { color: var(--color-success); background: #ffffff; border: 1px solid rgba(46, 204, 113, 0.2); }

.insight-card.danger {
  background: linear-gradient(to right, rgba(242, 22, 81, 0.05), rgba(242, 22, 81, 0.01));
  border-left: 5px solid var(--color-danger);
}
.insight-card.danger .insight-icon { color: var(--color-danger); background: #ffffff; border: 1px solid rgba(242, 22, 81, 0.2); }

.insight-card.warning {
  background: linear-gradient(to right, rgba(249, 146, 28, 0.05), rgba(249, 146, 28, 0.01));
  border-left: 5px solid var(--color-warning);
}
.insight-card.warning .insight-icon { color: var(--color-warning); background: #ffffff; border: 1px solid rgba(249, 146, 28, 0.2); }

/* Grid System */
.grid { display: grid; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-navy { color: var(--color-navy); }

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-6 { margin-top: 1.5rem; }

/* Responsive Grid */
@media (min-width: 768px) {
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lg\:col-span-2 { grid-column: span 2 / span 2; }
}

/* Tooltips */
/* Tooltips */
[data-tooltip] {
  position: relative;
  cursor: help;
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-color: rgba(2, 24, 61, 0.3);
  text-decoration-thickness: 1px;
}

/* Tooltips for cards/panels shouldn't have underline */
.kpi-card[data-tooltip],
.panel[data-tooltip] {
  text-decoration: none;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 100%; /* Move to bottom */
  left: 50%;
  transform: translateX(-50%);
  
  background: var(--color-navy);
  color: white;
  padding: 1rem;
  border-radius: 8px;
  
  font-size: 0.85rem;
  line-height: 1.5;
  font-weight: 500;
  text-align: center;
  
  white-space: pre-wrap;
  width: max-content;
  max-width: 280px;
  
  z-index: 9999;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  margin-top: 12px;
  
  opacity: 0;
  animation: tooltip-slide-down 0.2s forwards;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.1);
}

[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  top: 100%; /* Move to bottom */
  left: 50%;
  transform: translateX(-50%);
  
  border: 8px solid transparent;
  border-bottom-color: var(--color-navy); /* Point up */
  margin-top: -4px;
  
  opacity: 0;
  animation: tooltip-slide-down 0.2s forwards;
  z-index: 9999;
}

@keyframes tooltip-slide-down {
  from { opacity: 0; margin-top: 0; }
  to { opacity: 1; margin-top: 12px; }
}

/* =========================================
   Collapsible Sidebar Enhancement
   ========================================= */

/* =========================================
   Master Report Button Styles
   ========================================= */
.download-master-btn {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.download-master-btn .nav-text {
  color: #10B981;
  font-weight: 600;
}

.download-master-btn:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.4);
}


/* =========================================
   Sidebar Collapsed State
   ========================================= */
.sidebar.collapsed {
  width: 80px;
}

/* Hide text elements in collapsed mode */
.sidebar.collapsed .nav-text,
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-category,
.sidebar.collapsed .phase-label,
.sidebar.collapsed .phase-value,
.sidebar.collapsed .version-text,
.sidebar.collapsed .chat-title,
.sidebar.collapsed .chat-expand-icon,
.sidebar.collapsed .footer-info {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* Adjust Layout for Collapsed Mode */
.sidebar.collapsed .brand {
  justify-content: center;
  padding: 0;
}

.sidebar.collapsed .brand-logo-img {
  margin: 0;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0.8rem 0;
}

.sidebar.collapsed .nav-icon {
  margin-right: 0;
  font-size: 1.2rem;
}

.sidebar.collapsed .toggle-icon {
  transform: rotate(180deg);
}

/* Footer Adjustments */
.sidebar.collapsed .sidebar-footer {
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.sidebar.collapsed .nav-item.logout-btn {
  margin-top: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Chat Widget Collapsed - Show only icon */
.sidebar.collapsed .ai-chat-widget {
  margin: 0.5rem;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.sidebar.collapsed .chat-header {
  padding: 0;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.sidebar.collapsed .chat-icon {
  margin: 0;
  font-size: 1.5rem;
}

.sidebar.collapsed .chat-body {
  display: none !important; /* Force hide body even if expanded styles persist */
}

/* Tooltip fix for collapsed items */
.sidebar.collapsed .nav-item[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: var(--color-navy);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.8rem;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  margin-left: 10px;
}
.sidebar-toggle {
    position: absolute;
    top: 50%;
    right: -18px;
    transform: translateY(-50%);
    width: 36px;
    height: 56px;
    background: linear-gradient(180deg, var(--color-navy-light) 0%, var(--color-pink) 100%);
    border: 1px solid rgba(255,255,255,0.8);
    border-radius: 999px;
    color: white;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    z-index: 100;
    transition: all 0.3s ease;
    box-shadow: 0 6px 16px rgba(2, 24, 61, 0.25);
    cursor: ew-resize;
  }
  
.sidebar-toggle:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 10px 20px rgba(2, 24, 61, 0.3);
  }

.sidebar-toggle:focus-visible {
  outline: 2px solid rgba(242, 22, 81, 0.7);
  outline-offset: 2px;
}

.toggle-grip {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  box-shadow:
    0 -8px 0 rgba(255,255,255,0.7),
    0 8px 0 rgba(255,255,255,0.7);
}

.toggle-icon {
    transition: transform 0.3s ease;
  }

/* Sidebar in collapsed state */
.sidebar.collapsed {
  width: 72px;
}

.sidebar.collapsed .brand-text {
  display: none;
}

.sidebar.collapsed .nav-text {
  display: none;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0.75rem;
}

.sidebar.collapsed .nav-icon {
  margin-right: 0;
  font-size: 1.25rem;
}

.sidebar.collapsed .sidebar-footer {
  padding: 0.75rem;
}

.sidebar.collapsed .phase-section {
  flex-direction: column;
  text-align: center;
}

.sidebar.collapsed .phase-label,
.sidebar.collapsed .phase-value {
  font-size: 0.6rem;
}

.sidebar.collapsed .version-badge {
  padding: 0.5rem;
}

.sidebar.collapsed .version-text {
  display: none;
}

.sidebar.collapsed .version-icon {
  font-size: 1rem;
}

/* Nav Text (for collapse behavior) */
.nav-text {
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s ease;
}

/* Sidebar Footer Styling */
.sidebar-footer {
  padding: 1.25rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.15) 100%);
}

.phase-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
}

.phase-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.phase-value {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-pink);
}

.version-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: linear-gradient(135deg, rgba(242, 22, 81, 0.15) 0%, rgba(145, 55, 147, 0.15) 100%);
  border-radius: 20px;
  border: 1px solid rgba(242, 22, 81, 0.3);
  transition: all 0.2s ease;
}

.version-badge:hover {
  background: linear-gradient(135deg, rgba(242, 22, 81, 0.25) 0%, rgba(145, 55, 147, 0.25) 100%);
  transform: translateY(-1px);
}

.version-icon {
  font-size: 0.8rem;
  color: var(--color-pink);
}

.version-text {
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  letter-spacing: 0.02em;
}

/* Brand Highlight Color */
.brand-highlight {
  color: var(--color-pink);
}

/* Export Button Styling */
.btn-export {
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  color: white;
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  cursor: pointer;
}

.btn-export:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  /* Sidebar Mobile - Overlay Mode */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    width: 260px; /* Ancho completo al abrir */
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .sidebar.collapsed {
    transform: translateX(0); /* "Collapsed" en movil significa ABIERTO para usar la misma logica del toggle */
    width: 260px;
  }
  
  /* Cuando el sidebar está abierto, poner un overlay oscuro en el main */
  .sidebar.collapsed + .main-wrapper::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 19;
    backdrop-filter: blur(2px);
  }

  .sidebar-toggle {
    right: -40px; /* Mas visible */
    width: 40px;
    height: 40px;
    border-radius: 0 8px 8px 0;
    top: 120px; /* Mas abajo para no tapar header brand */
  }

  /* Top Bar Vertical Layout */
  .top-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
    height: auto;
    gap: 1rem;
  }

  .time-travel {
    width: 100%;
    max-width: none;
  }

  .time-travel-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .time-granularity {
    width: 100%;
    display: flex;
    justify-content: space-between;
  }
  
  .gran-btn {
    flex: 1;
    text-align: center;
    padding: 0.4rem 0.2rem;
    font-size: 0.7rem;
  }

  .time-nav {
    display: flex;
    justify-content: space-between;
    width: 100%;
  }

  .time-nav-btn {
    flex: 1;
    justify-content: center;
  }

  /* Ocultar texto del boton exportar en movil */
  .btn-export span:last-child {
    display: none;
  }
  
  .btn-export {
    padding: 0.5rem;
    border-radius: 8px;
  }

  /* View Content & Grids */
  .view-content {
    padding: 1rem;
  }

  /* Forzar 1 columna en KPIs y Paneles */
  .grid-cols-1, 
  .grid-cols-2, 
  .grid-cols-3, 
  .grid-cols-4,
  .md\:grid-cols-2,
  .md\:grid-cols-4,
  .lg\:grid-cols-2,
  .lg\:grid-cols-3,
  .lg\:grid-cols-4 {
    grid-template-columns: 1fr !important;
  }

  .lg\:col-span-2 {
    grid-column: span 1 !important;
  }

  /* Tablas con scroll horizontal */
  .panel {
    padding: 1rem;
    overflow: hidden; /* Contener el overflow */
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  /* Wrapper para tabla que permite scroll */
  .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table {
    min-width: 600px; /* Forzar ancho mínimo para activar scroll */
  }

  /* Insight Cards */
  .insight-card {
    flex-direction: column;
    gap: 1rem;
  }

  .insight-icon {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .insight-title {
    font-size: 1rem;
  }
}
