/* /public/rentabilidades/rentabilidades.css */
/* Dashboard Dirección General - Sistema de Diseño Mercury Bank */

/* ========== IMPORTAR FUENTE INTER ========== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

/* ========== VARIABLES DE DISEÑO ========== */
:root {
  /* Paleta Mercury Bank */
  --primary-500: #6273FF;
  --primary-600: #4E5FE6;
  --primary-50: #EEF0FE;

  --neutral-900: #0F172A;
  --neutral-800: #1E293B;
  --neutral-700: #475569;
  --neutral-600: #64748B;
  --neutral-500: #94A3B8;
  --neutral-400: #CBD5E1;
  --neutral-300: #E2E8F0;
  --neutral-200: #E2E8F0;
  --neutral-100: #F1F5F9;
  --neutral-50: #F8FAFC;

  --success-600: #16A34A;
  --success-500: #22C55E;
  --success-50: #DCFCE7;

  --warning-600: #D97706;
  --warning-500: #F59E0B;
  --warning-50: #FEF3C7;

  --danger-600: #DC2626;
  --danger-500: #EF4444;
  --danger-50: #FEE2E2;

  --info-600: #0284C7;
  --info-500: #0EA5E9;
  --info-50: #E0F2FE;

  /* Sombras */
  --shadow-xs: 0 1px 2px 0 rgb(15 23 42 / 0.04);
  --shadow-sm: 0 1px 3px 0 rgb(15 23 42 / 0.08);
  --shadow-md: 0 4px 6px -1px rgb(15 23 42 / 0.08);
  --shadow-lg: 0 10px 15px -3px rgb(15 23 42 / 0.08);
  --shadow-xl: 0 20px 25px -5px rgb(15 23 42 / 0.10);

  /* Bordes */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transiciones */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== RESET Y BASE ========== */
* {
  box-sizing: border-box;
}

.rentabilidades-container {
  width: 100%;
  max-width: 1280px;
  min-width: 0;
  padding: 24px;
  margin: 0 auto;
  background: radial-gradient(circle at top right, rgba(98, 115, 255, 0.12), transparent 45%), var(--neutral-50);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.rentabilidades-container svg { width: 20px; height: 20px; }

/* ========== HEADER ========== */
.rentabilidades-header {
  background: white;
  padding: 24px;
  margin-bottom: 24px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--neutral-200);
}

.header-top {
  margin-bottom: 24px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--neutral-900);
  margin: 0 0 8px 0;
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--neutral-600);
  margin: 0;
  font-weight: 400;
}

/* ========== TOPBAR ========== */
.rentabilidades-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-avatar {
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  background: var(--primary-50);
  color: var(--primary-500);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-pill {
  width: 48px;
  padding: 0;
}

.avatar-icon { width: 18px; height: 18px; }

/* ========== CONTROLES ========== */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 20px;
}

.controls-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  flex: 1;
}

.controls-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
}

.control-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--neutral-700);
  letter-spacing: -0.01em;
}

.control-select,
.control-input {
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--neutral-300);
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 400;
  color: var(--neutral-900);
  background: white;
  transition: all var(--transition-fast);
  font-family: 'Inter', sans-serif;
}

.control-select:hover,
.control-input:hover {
  border-color: var(--neutral-400);
}

.control-select:focus,
.control-input:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px var(--primary-50);
}

/* ========== BOTONES ========== */
.btn-primary,
.btn-ghost,
.btn-icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 22px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
  letter-spacing: -0.01em;
}

.btn-primary {
  background: var(--primary-500);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--primary-600);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: white;
  color: var(--neutral-700);
  border: 1px solid var(--neutral-300);
}

.btn-ghost:hover {
  background: var(--neutral-50);
  border-color: var(--neutral-400);
}

.btn-icon-only {
  width: 48px;
  padding: 0;
  background: white;
  color: var(--neutral-600);
  border: 1px solid var(--neutral-300);
}

.btn-icon-only:hover {
  background: var(--neutral-50);
  color: var(--neutral-900);
}

.btn-icon,
.btn-icon-only .icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

/* ========== RANGE BADGE ========== */
.range-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--primary-50);
  color: var(--primary-600);
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
}

.range-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2.5;
}

/* ========== QUICKBOOKS MINIMAL CARD ========== */
.qb-mini-card {
  margin-top: 12px;
  background: #fff;
  border: 1px solid var(--neutral-200);
  border-radius: 14px;
  padding: 12px 14px;
}

.qb-mini-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.qb-mini-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--neutral-600);
}

.qb-mini-status {
  font-size: 13px;
  font-weight: 600;
  color: var(--neutral-900);
  margin-top: 2px;
}

.qb-mini-subtitle {
  font-size: 12px;
  color: var(--neutral-600);
  margin-top: 2px;
}

.qb-mini-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.qb-mini-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--neutral-100);
  color: var(--neutral-700);
}

.qb-mini-badge.success {
  background: var(--success-50);
  color: var(--success-600);
}

.qb-mini-badge.warning {
  background: var(--warning-50);
  color: var(--warning-600);
}

.qb-mini-message {
  margin-top: 8px;
  font-size: 12px;
  color: var(--neutral-600);
}

/* ========== LOADER ========== */
.loader-overlay {
  position: fixed;
  top: 20px;
  right: 20px;
  left: auto;
  bottom: auto;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.loader-overlay.hidden {
  display: none;
}

.loader-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-text {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.94);
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.01em;
}

/* ========== CONTENIDO ========== */
.rentabilidades-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.rentabilidades-content.dashboard-refreshing .hero-value,
.rentabilidades-content.dashboard-refreshing .financial-value,
.rentabilidades-content.dashboard-refreshing .financial-pct,
.rentabilidades-content.dashboard-refreshing .hero-badge,
.rentabilidades-content.dashboard-refreshing .dg-table td {
  animation: dashboardPulse 0.9s ease-in-out infinite alternate;
}

.value-updating {
  color: var(--primary-600);
  transition: color 0.25s ease;
}

@keyframes dashboardPulse {
  from { opacity: 1; }
  to { opacity: 0.66; }
}

/* ========== SECCIONES ========== */
.kpi-section {
  background: white;
  padding: 24px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--neutral-200);
}

.kpi-section.hidden {
  display: none;
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--neutral-900);
  margin: 0 0 20px 0;
  letter-spacing: -0.02em;
}

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

.section-header-with-actions .section-title {
  margin: 0;
}

/* ========== DIRECCION GENERAL (P&L) ========== */
.dg-section {
  position: relative;
}

.dg-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.dg-title .section-title {
  margin-bottom: 6px;
}

.dg-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--neutral-600);
}

.dg-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.dg-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 160px;
}

.dg-input-wrap {
  position: relative;
}

.dg-input {
  padding-right: 36px;
  width: 120px;
}

.dg-input-suffix {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 600;
  color: var(--neutral-500);
  pointer-events: none;
}

.dg-segment {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-full);
  background: var(--neutral-100);
  border: 1px solid var(--neutral-200);
}

.dg-seg-btn {
  border: none;
  background: transparent;
  color: var(--neutral-600);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: -0.01em;
}

.dg-seg-btn:hover {
  color: var(--neutral-900);
}

.dg-seg-btn.is-active {
  background: white;
  color: var(--neutral-900);
  border: 1px solid var(--neutral-200);
  box-shadow: var(--shadow-xs);
}

.dg-inline-note {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--neutral-200);
  background: var(--neutral-50);
  color: var(--neutral-600);
  font-size: 12px;
  display: none;
}

.dg-inline-note.is-visible {
  display: block;
}

.dg-table-card {
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  background: white;
  box-shadow: var(--shadow-sm);
}

.dg-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dg-table {
  width: 100%;
  min-width: 1100px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.dg-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--neutral-900);
  color: white;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  padding: 12px 14px;
  white-space: nowrap;
}

.dg-col-meta {
  display: block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--neutral-300);
  margin-top: 4px;
}

.dg-table th.dg-sticky,
.dg-table td.dg-sticky {
  position: sticky;
  left: 0;
  z-index: 3;
}

.dg-table thead th.dg-sticky {
  z-index: 4;
}

.dg-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--neutral-200);
  color: var(--neutral-700);
  background: white;
}

.dg-table tbody td.dg-sticky {
  font-weight: 600;
  color: var(--neutral-900);
  box-shadow: 2px 0 0 0 var(--neutral-200);
}

.dg-table tbody tr:nth-child(even) td {
  background: var(--neutral-50);
}

.dg-table tbody tr:nth-child(even) td.dg-sticky {
  background: var(--neutral-50);
}

.dg-table tbody tr:hover td {
  background: var(--neutral-100);
}

.dg-table tbody tr:hover td.dg-sticky {
  background: var(--neutral-100);
}

.dg-table tbody tr.dg-row-total td {
  background: var(--neutral-50);
  font-weight: 600;
  border-top: 1px solid var(--neutral-200);
}

.dg-table tbody tr.dg-row-total td.dg-sticky {
  background: var(--neutral-50);
}

.dg-table tbody tr.dg-row-elimination td {
  background: #FEF3C7;
  color: #92400E;
  font-style: italic;
  border-top: 1px dashed #FCD34D;
}

.dg-table tbody tr.dg-row-elimination td.dg-sticky {
  background: #FEF3C7;
  font-weight: 600;
  font-style: normal;
}

.dg-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dg-value {
  font-weight: 600;
  color: var(--neutral-900);
}

.dg-sub {
  font-size: 11px;
  color: var(--neutral-600);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dg-status {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.dg-status.success {
  background: var(--success-50);
  color: var(--success-600);
}

.dg-status.warning {
  background: var(--warning-50);
  color: var(--warning-600);
}

.dg-status.danger {
  background: var(--danger-50);
  color: var(--danger-600);
}

.dg-scroll-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--neutral-500);
  display: none;
}

/* ========== HERO CARDS (KPIs Principales) ========== */
.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.hero-card {
  background: white;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--neutral-300);
  transition: background var(--transition-fast);
}

.hero-card.primary::before { background: var(--primary-500); }
.hero-card.success::before { background: var(--success-500); }
.hero-card.warning::before { background: var(--warning-500); }
.hero-card.info::before { background: var(--info-500); }

.hero-card:hover {
  border-color: var(--neutral-400);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.hero-card.featured {
  grid-column: span 2;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.12), rgba(255, 255, 255, 0.95));
  border-color: rgba(34, 197, 94, 0.4);
  box-shadow: var(--shadow-lg);
}

.hero-card.featured .hero-value {
  font-size: 40px;
}

.hero-card.featured .hero-label {
  color: var(--neutral-800);
}

.hero-card.featured .hero-meta-text {
  font-weight: 600;
}

@media (max-width: 1024px) {
  .hero-card.featured {
    grid-column: span 1;
  }
}

.hero-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.hero-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hero-icon-wrapper.primary {
  background: var(--primary-50);
  color: var(--primary-600);
}

.hero-icon-wrapper.success {
  background: var(--success-50);
  color: var(--success-600);
}

.hero-icon-wrapper.warning {
  background: var(--warning-50);
  color: var(--warning-600);
}

.hero-icon-wrapper.info {
  background: var(--info-50);
  color: var(--info-600);
}

.hero-icon {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.hero-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--neutral-700);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hero-value {
  font-size: 34px;
  font-weight: 700;
  color: var(--neutral-900);
  margin-bottom: 12px;
  line-height: 1;
  letter-spacing: -0.03em;
}

.hero-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}

.hero-change {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  width: fit-content;
}

.hero-change.positive {
  background: var(--success-50);
  color: var(--success-600);
}

.hero-change.negative {
  background: var(--danger-50);
  color: var(--danger-600);
}

.hero-change.neutral {
  background: var(--neutral-100);
  color: var(--neutral-600);
}

.hero-meta-text {
  color: var(--neutral-600);
  font-size: 13px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--neutral-100);
  color: var(--neutral-700);
  font-weight: 600;
  font-size: 13px;
  width: fit-content;
}

.hero-badge.success {
  background: var(--success-50);
  color: var(--success-600);
}

.hero-badge.green {
  background: var(--success-50);
  color: var(--success-600);
}

.hero-badge.yellow {
  background: var(--warning-50);
  color: var(--warning-600);
}

.hero-badge.red {
  background: var(--danger-50);
  color: var(--danger-600);
}

.hero-breakdown {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--neutral-200);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.breakdown-item-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--neutral-700);
}

.breakdown-item-inline strong {
  font-weight: 700;
  color: var(--neutral-900);
}

.breakdown-subtle {
  color: var(--neutral-500);
  font-size: 12px;
  font-weight: 500;
}

.breakdown-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.breakdown-dot.food {
  background: var(--warning-500);
}

.breakdown-dot.labor {
  background: var(--info-500);
}

/* NPS Breakdown */
.nps-breakdown {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
}

.nps-promoters {
  color: var(--success-600);
}

.nps-detractors {
  color: var(--danger-600);
}

.nps-separator {
  color: var(--neutral-400);
}

.nps-note {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--neutral-500);
}

/* ========== KPI GRID (Métricas Secundarias) ========== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.kpi-card {
  background: white;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition-base);
}

.kpi-card:hover {
  border-color: var(--neutral-400);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.kpi-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.kpi-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  color: var(--neutral-600);
}

.kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--neutral-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--neutral-900);
  margin-bottom: 8px;
  line-height: 1;
  letter-spacing: -0.02em;
}

.kpi-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--neutral-600);
  flex-wrap: wrap;
}

.kpi-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--neutral-100);
  color: var(--neutral-700);
  font-weight: 600;
  font-size: 12px;
}

.kpi-badge.green {
  background: var(--success-50);
  color: var(--success-600);
}

.kpi-badge.yellow {
  background: var(--warning-50);
  color: var(--warning-600);
}

.kpi-badge.red {
  background: var(--danger-50);
  color: var(--danger-600);
}

.kpi-meta-text {
  color: var(--neutral-600);
  font-size: 13px;
}

.help-icon {
  margin-left: auto;
  width: 22px;
  height: 22px;
  border-radius: 9999px;
  border: 1px solid var(--neutral-300);
  background: #fff;
  color: var(--neutral-700);
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 9999; /* z-index alto para asegurar que esté encima de todo */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.help-modal.hidden {
  display: none;
}

.help-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: -1;
}

.help-modal-card {
  position: relative;
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--neutral-200);
  box-shadow: 0 24px 64px rgba(2, 6, 23, 0.24);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.help-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--neutral-200);
  font-weight: 700;
  flex-shrink: 0;
}

.help-modal-body {
  padding: 16px 18px;
  color: var(--neutral-700);
  font-size: 14px;
  line-height: 1.5;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.help-block {
  margin-bottom: 14px;
}

.help-block h4 {
  margin: 0 0 6px 0;
  font-size: 14px;
  color: var(--neutral-900);
}

.help-block p {
  margin: 0 0 8px 0;
}

.help-block ul {
  margin: 0;
  padding-left: 16px;
}

.help-block li {
  margin: 0 0 6px 0;
}

.help-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  border-radius: 12px;
  padding: 10px 12px;
}

.help-modal-close {
  border: 1px solid var(--neutral-200);
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  font-weight: 600;
  cursor: pointer;
}

/* ========== BODY MODAL STATE ========== */
body.modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* ========== COMPARATIVO MODAL ========== */
.comparativo-modal {
  position: fixed;
  inset: 0;
  z-index: 9999; /* z-index alto para asegurar que esté encima de todo */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px; /* padding para que no toque los bordes */
  box-sizing: border-box;
}

.comparativo-modal.hidden {
  display: none;
}

.comparativo-modal-backdrop {
  position: fixed; /* Cambiado a fixed para que cubra toda la pantalla */
  inset: 0;
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.45), rgba(2, 6, 23, 0.6));
  z-index: -1; /* Detrás del contenido del modal */
}

.comparativo-modal-card {
  position: relative;
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: hidden; /* Cambiado a hidden para manejar scroll interno */
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--neutral-200);
  box-shadow: 0 28px 68px rgba(2, 6, 23, 0.3);
}

.comparativo-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--neutral-200);
  flex-shrink: 0; /* No se comprime */
}

.comparativo-modal-title h3 {
  margin: 0;
  font-size: 18px;
  color: var(--neutral-900);
}

.comparativo-modal-range {
  display: block;
  font-size: 12px;
  color: var(--neutral-500);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.comparativo-modal-body {
  padding: 18px 20px 22px;
  display: grid;
  gap: 16px;
  overflow-y: auto; /* Scroll interno en el body */
  flex: 1;
  min-height: 0; /* Importante para que flex + overflow funcione */
  -webkit-overflow-scrolling: touch; /* Smooth scroll en iOS */
}

.comparativo-modal-legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--neutral-700);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.comparativo-modal-content {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 0.9fr);
  gap: 18px;
}

@media (max-width: 900px) {
  .comparativo-modal-content {
    grid-template-columns: 1fr;
  }
}

.comparativo-race {
  display: grid;
  gap: 14px;
}

.race-lane {
  background: var(--neutral-50);
  border: 1px solid var(--neutral-200);
  border-radius: 14px;
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}

.race-lane-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.race-rank {
  font-weight: 700;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--neutral-200);
  color: var(--neutral-700);
}

.race-rank.gold {
  background: #fef3c7;
  color: #92400e;
}

.race-rank.silver {
  background: #e2e8f0;
  color: #334155;
}

.race-rank.bronze {
  background: #fde7d2;
  color: #9a3412;
}

.race-name {
  font-weight: 700;
  color: var(--neutral-900);
}

.race-score {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-600);
}

.race-track {
  position: relative;
  height: 20px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, #0f172a 0%, #111827 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.race-track::before {
  content: '';
  position: absolute;
  inset: 50% 10px auto 10px;
  height: 2px;
  transform: translateY(-50%);
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.55) 0 10px, transparent 10px 22px);
  opacity: 0.6;
}

.race-track::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 45%);
}

.race-progress {
  position: relative;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #6273FF);
  border-radius: 999px;
  box-shadow: inset 0 0 12px rgba(59, 130, 246, 0.35);
}

.race-car {
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 12px;
  background: linear-gradient(90deg, #f97316 0%, #fb7185 100%);
  border-radius: 6px 10px 10px 6px;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.35);
}

.race-car::before {
  content: '';
  position: absolute;
  left: 6px;
  bottom: -4px;
  width: 8px;
  height: 8px;
  background: #0f172a;
  border-radius: 999px;
  box-shadow:
    12px 0 0 #0f172a,
    0 0 0 2px #e2e8f0 inset,
    12px 0 0 2px #e2e8f0 inset;
}

.race-car::after {
  content: '';
  position: absolute;
  right: 4px;
  top: 2px;
  width: 12px;
  height: 6px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 2px 6px 6px 2px;
  opacity: 0.85;
}

.race-finish {
  position: absolute;
  right: 8px;
  top: 0;
  bottom: 0;
  width: 8px;
  background: repeating-linear-gradient(90deg, #0f172a 0 4px, #fff 4px 8px);
  opacity: 0.7;
}

.race-metrics {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--neutral-200);
  font-size: 11px;
  font-weight: 700;
  color: var(--neutral-700);
}

.comparativo-podium {
  display: grid;
  gap: 12px;
}

.podium-card {
  border: 1px solid var(--neutral-200);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  display: grid;
  gap: 8px;
}

.podium-card.gold {
  border-color: #f59e0b;
  background: linear-gradient(145deg, #fff7ed 0%, #fff 100%);
}

.podium-card.silver {
  border-color: #94a3b8;
  background: linear-gradient(145deg, #f8fafc 0%, #fff 100%);
}

.podium-card.bronze {
  border-color: #fb923c;
  background: linear-gradient(145deg, #fff7ed 0%, #fff 100%);
}

.podium-rank {
  font-weight: 700;
  font-size: 12px;
  color: var(--neutral-600);
}

.podium-name {
  font-weight: 700;
  color: var(--neutral-900);
}

.podium-metrics {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--neutral-600);
}

/* ========== FINANCIAL GRID ========== */
.financial-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.financial-card {
  background: white;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition-base);
}

.financial-card:hover {
  border-color: var(--neutral-400);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.financial-card.highlight {
  background: linear-gradient(135deg, var(--primary-50) 0%, white 100%);
  border-color: var(--primary-500);
}

.financial-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.financial-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  color: var(--neutral-600);
}

.financial-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--neutral-700);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.financial-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--neutral-900);
  margin-bottom: 12px;
  line-height: 1;
  letter-spacing: -0.03em;
}

.financial-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.financial-block-message {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: #7F1D1D;
  background: linear-gradient(135deg, #FEF2F2 0%, #FEE2E2 100%);
  border: 1px solid #FCA5A5;
}

.financial-pct {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--neutral-100);
  color: var(--neutral-700);
  font-weight: 700;
  font-size: 14px;
}

.financial-pct.success {
  background: var(--success-50);
  color: var(--success-600);
}

.financial-pct.warning {
  background: var(--warning-50);
  color: var(--warning-600);
}

.financial-pct.danger {
  background: var(--danger-50);
  color: var(--danger-600);
}

.financial-meta-text {
  color: var(--neutral-600);
  font-size: 13px;
}

.financial-note {
  margin-top: 10px;
  font-size: 11px;
  color: var(--neutral-500);
}

.financial-bar {
  width: 100%;
  height: 6px;
  background: var(--neutral-100);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.financial-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.financial-bar-fill.food {
  background: linear-gradient(90deg, var(--warning-500) 0%, var(--warning-600) 100%);
}

.financial-bar-fill.labor {
  background: linear-gradient(90deg, var(--info-500) 0%, var(--info-600) 100%);
}

.financial-bar-fill.opex {
  background: linear-gradient(90deg, var(--warning-500) 0%, var(--warning-600) 100%);
}

/* ========== NOMINA STACK ========== */
.nomina-stack {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.nomina-row {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--neutral-50);
}

.nomina-row.is-active {
  border-color: var(--primary-300);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(255, 255, 255, 0.9));
}

.nomina-row.is-unavailable {
  opacity: 0.65;
}

.nomina-row-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.nomina-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--neutral-700);
}

.nomina-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.nomina-badge.live {
  background: var(--info-50);
  color: var(--info-700);
}

.nomina-badge.payroll {
  background: var(--success-50);
  color: var(--success-700);
}

.nomina-state {
  font-size: 12px;
  font-weight: 600;
  color: var(--neutral-500);
}

.nomina-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--neutral-900);
  letter-spacing: -0.02em;
}

.nomina-divider {
  height: 1px;
  background: var(--neutral-200);
  margin: 2px 0;
}

/* ========== GRÁFICOS ========== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 20px;
}

@media (max-width: 768px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background: white;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

.chart-card:hover {
  border-color: var(--neutral-400);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.chart-card.wide {
  grid-column: span 2;
}

/* Laptop pequeña (1200px - 1400px) - Fix para modales */
@media (max-width: 1400px) {
  .comparativo-modal-card {
    width: min(920px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
  }
}

@media (max-width: 1200px) {
  .chart-card.wide {
    grid-column: span 1;
  }

  /* Modal más compacto en laptops */
  .comparativo-modal-card {
    width: min(850px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
  }

  .comparativo-modal-content {
    grid-template-columns: 1fr; /* Una sola columna en laptops pequeñas */
    gap: 14px;
  }
}

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

.chart-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--neutral-900);
  margin: 0;
  letter-spacing: -0.01em;
}

.chart-meta {
  font-size: 13px;
  color: var(--neutral-600);
  font-weight: 500;
}

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

/* ========== TABLA COMPARATIVA ========== */
.comparativo-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.table-card {
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-wrapper {
  overflow-x: auto;
}

.comparativo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.comparativo-table thead {
  background: var(--neutral-900);
  color: white;
}

.comparativo-table th {
  padding: 16px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.comparativo-table td {
  padding: 16px;
  border-bottom: 1px solid var(--neutral-200);
  color: var(--neutral-700);
}

.comparativo-table tbody tr:hover {
  background: var(--neutral-50);
}

.comparativo-table tbody tr:last-child td {
  border-bottom: none;
}

.comparativo-table td strong {
  color: var(--neutral-900);
  font-weight: 600;
}

/* ========== NOMINA DETALLE ========== */
.detail-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-right: 8px;
  border: 1px solid var(--neutral-300);
  border-radius: 8px;
  background: #fff;
  color: var(--neutral-600);
  cursor: pointer;
  transition: all var(--transition-base);
}

.detail-toggle:hover {
  background: var(--neutral-50);
  border-color: var(--neutral-400);
}

.detail-icon {
  width: 16px;
  height: 16px;
}

.nomina-detail {
  padding: 16px;
  background: var(--neutral-50);
  border-top: 1px solid var(--neutral-200);
}

.nomina-detail-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--neutral-600);
}

.nomina-detail-label {
  font-weight: 600;
  color: var(--neutral-700);
}

.nomina-detail-select {
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--neutral-300);
  background: #fff;
  font-size: 12px;
  color: var(--neutral-700);
}

.nomina-detail-count strong {
  color: var(--neutral-900);
}

.nomina-detail-empty {
  padding: 16px;
  font-size: 13px;
  color: var(--neutral-600);
}

.text-right { text-align: right; }
.text-center { text-align: center; }

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 12px;
  background: var(--neutral-100);
  color: var(--neutral-700);
}

.rank-1 {
  background: #FEF3C7;
  color: #92400E;
}

.rank-2 {
  background: #E5E7EB;
  color: #374151;
}

.rank-3 {
  background: #FDE68A;
  color: #92400E;
}

.comparativo-row-muted {
  opacity: 0.4;
}

.comparativo-empty {
  padding: 12px 16px;
  color: var(--neutral-500);
  font-size: 13px;
}

/* ========== RESPONSIVE ========== */

/* Tablet y Mobile Grande (768px - 1024px) */
@media (max-width: 1024px) {
  .rentabilidades-container {
    padding: 16px;
  }

  .chart-card.wide {
    grid-column: span 1;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile Grande (480px - 768px) */
@media (max-width: 768px) {
  /* Contenedor principal con padding optimizado para mobile */
  .rentabilidades-container {
    padding: 12px;
    background: var(--neutral-50);
  }

  /* Header más compacto y touch-friendly */
  .rentabilidades-header {
    padding: 16px;
    margin-bottom: 16px;
    border-radius: var(--radius-lg);
  }

  .page-title {
    font-size: 22px;
  }

  .page-subtitle {
    font-size: 13px;
  }

  /* Topbar responsive con mejor UX mobile */
  .rentabilidades-topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  /* Controles touch-friendly */
  .controls-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }

  .controls-fields {
    flex-direction: column;
    gap: 12px;
  }

  .controls-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .control-group {
    min-width: unset;
  }

  .control-select,
  .control-input {
    height: 52px; /* Mayor altura para mobile */
    font-size: 16px; /* Evita zoom en iOS */
  }

  /* Botones más grandes para mobile */
  .btn-primary,
  .btn-ghost,
  .btn-icon-only {
    height: 52px;
    font-size: 15px;
    min-width: 52px;
  }

  .btn-icon {
    width: 22px;
    height: 22px;
  }

  /* Range badge adaptado */
  .range-badge {
    padding: 12px 16px;
    font-size: 13px;
    text-align: center;
    justify-content: center;
  }

  /* Contenido principal */
  .rentabilidades-content {
    gap: 16px;
  }

  /* Secciones optimizadas */
  .kpi-section {
    padding: 16px;
    margin-bottom: 0;
    border-radius: var(--radius-lg);
  }

  .section-title {
    font-size: 18px;
    margin-bottom: 16px;
  }

  .dg-header {
    flex-direction: column;
    align-items: stretch;
  }

  .dg-controls {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .dg-control {
    min-width: 0;
  }

  .dg-input {
    width: 100%;
  }

  .dg-segment {
    width: 100%;
    justify-content: space-between;
  }

  .dg-scroll-hint {
    display: block;
  }

  /* Hero cards single column con mejor espaciado */
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .hero-card {
    padding: 20px;
    border-radius: var(--radius-lg);
  }

  .hero-card:hover {
    transform: none; /* Desactivar transformación en mobile */
  }

  .hero-icon-wrapper {
    width: 48px;
    height: 48px;
  }

  .hero-icon {
    width: 24px;
    height: 24px;
  }

  .hero-value {
    font-size: 32px;
    margin-bottom: 14px;
  }

  .hero-meta {
    gap: 10px;
  }

  /* KPI cards optimizadas */
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .kpi-card {
    padding: 18px;
  }

  .kpi-card:hover {
    transform: none;
  }

  .kpi-value {
    font-size: 26px;
  }

  /* Financial cards */
  .financial-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .financial-card {
    padding: 20px;
  }

  .financial-card:hover {
    transform: none;
  }

  .financial-value {
    font-size: 30px;
  }

  /* Nómina stack mobile-friendly */
  .nomina-stack {
    gap: 12px;
  }

  .nomina-row {
    padding: 14px;
  }

  .nomina-value {
    font-size: 24px;
  }

  /* Charts con altura reducida para mobile */
  .chart-container {
    height: 250px;
  }

  .chart-card {
    padding: 16px;
    border-radius: var(--radius-lg);
  }

  .chart-card:hover {
    transform: none;
  }

  .chart-title {
    font-size: 15px;
  }

  .chart-meta {
    font-size: 12px;
  }

  /* Tabla comparativa scroll horizontal */
  .table-wrapper {
    -webkit-overflow-scrolling: touch;
  }

  .comparativo-table {
    font-size: 13px;
  }

  .comparativo-table th,
  .comparativo-table td {
    padding: 12px 10px;
  }

  /* Modal comparativo full-screen en mobile */
  .comparativo-modal {
    padding: 0; /* Sin padding en mobile para full-screen */
  }

  .comparativo-modal-card {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    margin: 0;
  }

  .comparativo-modal-content {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .comparativo-modal-body {
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Help modal ajustado */
  .help-modal {
    padding: 8px;
  }

  .help-modal-card {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }

  .help-modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Avatar y iconos */
  .topbar-avatar {
    width: 44px;
    height: 44px;
  }

  .icon-pill {
    width: 52px;
  }
}

/* Mobile Pequeño (320px - 480px) */
@media (max-width: 480px) {
  /* Contenedor con padding mínimo */
  .rentabilidades-container {
    padding: 8px;
  }

  /* Header ultra-compacto */
  .rentabilidades-header {
    padding: 12px;
  }

  .header-top {
    margin-bottom: 16px;
  }

  .page-title {
    font-size: 20px;
    margin-bottom: 6px;
  }

  .page-subtitle {
    font-size: 12px;
  }

  /* Topbar ajustado */
  .rentabilidades-topbar {
    gap: 10px;
    margin-bottom: 14px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .topbar-avatar {
    width: 40px;
    height: 40px;
  }

  .avatar-icon {
    width: 16px;
    height: 16px;
  }

  /* Controles compactos */
  .controls-bar {
    gap: 10px;
  }

  .controls-fields {
    gap: 10px;
  }

  .control-label {
    font-size: 13px;
  }

  .control-select,
  .control-input {
    height: 48px;
    padding: 0 14px;
    font-size: 15px;
  }

  /* Botones optimizados */
  .btn-primary,
  .btn-ghost,
  .btn-icon-only {
    height: 48px;
    padding: 0 18px;
    font-size: 14px;
    min-width: 48px;
  }

  .btn-icon {
    width: 20px;
    height: 20px;
  }

  .icon-pill {
    width: 48px;
  }

  /* Range badge compacto */
  .range-badge {
    padding: 10px 14px;
    font-size: 12px;
  }

  .range-icon {
    width: 18px;
    height: 18px;
  }

  /* Secciones compactas */
  .kpi-section {
    padding: 14px;
  }

  .section-title {
    font-size: 17px;
    margin-bottom: 14px;
  }

  /* Hero cards ultra-compactas */
  .hero-grid {
    gap: 12px;
  }

  .hero-card {
    padding: 16px;
  }

  .hero-icon-wrapper {
    width: 42px;
    height: 42px;
  }

  .hero-icon {
    width: 22px;
    height: 22px;
  }

  .hero-label {
    font-size: 12px;
  }

  .hero-value {
    font-size: 28px;
    margin-bottom: 12px;
  }

  .hero-meta {
    font-size: 12px;
    gap: 8px;
  }

  .hero-change,
  .hero-badge {
    padding: 5px 10px;
    font-size: 12px;
  }

  .hero-breakdown {
    margin-top: 12px;
    padding-top: 12px;
    gap: 6px;
  }

  .breakdown-item-inline {
    font-size: 12px;
    gap: 6px;
  }

  /* KPI cards compactas */
  .kpi-grid {
    gap: 10px;
  }

  .kpi-card {
    padding: 16px;
  }

  .kpi-icon {
    width: 18px;
    height: 18px;
  }

  .kpi-label {
    font-size: 12px;
  }

  .kpi-value {
    font-size: 24px;
    margin-bottom: 10px;
  }

  .kpi-meta {
    font-size: 12px;
  }

  .kpi-badge {
    padding: 4px 8px;
    font-size: 11px;
  }

  .help-icon {
    width: 20px;
    height: 20px;
    font-size: 11px;
  }

  /* Financial cards compactas */
  .financial-grid {
    gap: 12px;
  }

  .financial-card {
    padding: 16px;
  }

  .financial-icon {
    width: 18px;
    height: 18px;
  }

  .financial-label {
    font-size: 12px;
  }

  .financial-value {
    font-size: 26px;
    margin-bottom: 10px;
  }

  .financial-pct {
    padding: 5px 10px;
    font-size: 13px;
  }

  .financial-meta-text {
    font-size: 12px;
  }

  /* Nómina stack compacta */
  .nomina-stack {
    gap: 10px;
  }

  .nomina-row {
    padding: 12px;
  }

  .nomina-title {
    font-size: 11px;
  }

  .nomina-badge {
    font-size: 10px;
    padding: 3px 7px;
  }

  .nomina-state {
    font-size: 11px;
  }

  .nomina-value {
    font-size: 22px;
  }

  /* Charts compactos */
  .chart-container {
    height: 220px;
  }

  .chart-card {
    padding: 14px;
  }

  .chart-title {
    font-size: 14px;
  }

  .chart-meta {
    font-size: 11px;
  }

  /* Tabla comparativa muy compacta */
  .comparativo-table {
    font-size: 12px;
  }

  .comparativo-table th,
  .comparativo-table td {
    padding: 10px 8px;
  }

  .rank-badge {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  /* Modal help compacto */
  .help-modal-card {
    width: 98vw;
    margin: 2vh auto 0;
  }

  .help-modal-header {
    padding: 12px 14px;
    font-size: 14px;
  }

  .help-modal-body {
    padding: 14px;
    font-size: 13px;
    max-height: 70vh;
  }

  .help-block h4 {
    font-size: 13px;
  }

  .help-modal-close {
    padding: 5px 8px;
    font-size: 12px;
  }

  /* Modal comparativo */
  .comparativo-modal-header {
    padding: 14px 16px;
  }

  .comparativo-modal-title h3 {
    font-size: 16px;
  }

  .comparativo-modal-range {
    font-size: 11px;
  }

  .comparativo-modal-legend {
    font-size: 12px;
  }

  .comparativo-modal-body {
    padding: 14px;
  }

  /* Race lanes compactas */
  .comparativo-race {
    gap: 12px;
  }

  .race-lane {
    padding: 10px 12px;
    gap: 8px;
  }

  .race-rank {
    font-size: 11px;
    padding: 3px 7px;
  }

  .race-name {
    font-size: 14px;
  }

  .race-score {
    font-size: 11px;
  }

  .race-track {
    height: 18px;
  }

  .race-car {
    width: 26px;
    height: 10px;
  }

  .metric-chip {
    font-size: 10px;
    padding: 3px 7px;
    gap: 5px;
  }

  /* Podium compacto */
  .comparativo-podium {
    gap: 10px;
  }

  .podium-card {
    padding: 10px 12px;
    gap: 6px;
  }

  .podium-rank {
    font-size: 11px;
  }

  .podium-name {
    font-size: 14px;
  }

  .podium-metrics {
    font-size: 11px;
    gap: 3px;
  }
}

/* Touch optimizations para todos los mobile */
@media (max-width: 768px) {
  /* Mejorar área de toque en todos los elementos interactivos */
  button,
  select,
  input[type="date"],
  a {
    -webkit-tap-highlight-color: rgba(98, 115, 255, 0.1);
  }

  /* Smooth scrolling */
  * {
    -webkit-overflow-scrolling: touch;
  }

  /* Desactivar hover effects en mobile */
  .hero-card:active {
    transform: scale(0.98);
  }

  .kpi-card:active {
    transform: scale(0.98);
  }

  .financial-card:active {
    transform: scale(0.98);
  }

  .btn-primary:active {
    transform: scale(0.95);
  }

  .btn-ghost:active {
    transform: scale(0.95);
  }

  /* Mejorar contraste para pantallas pequeñas */
  .hero-meta-text,
  .kpi-meta-text,
  .financial-meta-text {
    color: var(--neutral-700);
  }
}

/* ========== ANIMACIONES ========== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.hero-card,
.kpi-card,
.financial-card,
.chart-card {
  animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.hero-card:nth-child(1) { animation-delay: 0.05s; }
.hero-card:nth-child(2) { animation-delay: 0.1s; }
.hero-card:nth-child(3) { animation-delay: 0.15s; }
.hero-card:nth-child(4) { animation-delay: 0.2s; }

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

/* ========== UTILIDADES ========== */
.hidden {
  display: none !important;
}

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

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

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

.bg-success {
  background-color: var(--success-50);
}

.bg-warning {
  background-color: var(--warning-50);
}

.bg-danger {
  background-color: var(--danger-50);
}
