:root {
      --azul-principal: #0b4f8a;
      --azul-secundario: #0e63ad;
      --azul-profundo: #083b66;
      --dorado: #d4af37
    }

    html,
    body {
      font-family: Montserrat, sans-serif;
      margin: 0;
      padding: 0
    }

    body {
      background: #f5f7fa;
      color: #2f3a44
    }

    /*
      LOGIN OBLIGATORIO
      - Evita que se vea cualquier información antes de autenticar.
      - auth_gate.js quitará la clase auth-locked cuando el usuario tenga sesión válida.
    */
    body.auth-locked {
      overflow: hidden;
    }
    body.auth-locked > *:not(#kentiaLoginOverlay) {
      display: none !important;
    }
    body.auth-locked #kentiaLoginOverlay {
      display: flex !important;
    }

    .ef-header {
      background: linear-gradient(180deg, var(--azul-secundario), var(--azul-profundo));
      border-bottom: 6px solid var(--dorado)
    }

    .ef-select {
      background: rgba(255, 255, 255, 0.95);
      color: #111827;
      border: 1px solid rgba(212, 175, 55, .45);
      border-radius: 12px;
      padding: .55rem .85rem;
      outline: none
    }

    .ef-select:focus {
      box-shadow: 0 0 0 3px rgba(212, 175, 55, .25);
      border-color: rgba(212, 175, 55, .9)
    }

    .ef-nav {
      border-bottom: 2px solid rgba(212, 175, 55, .35);
      backdrop-filter: blur(8px)
    }

    .ef-nav button[data-tab] {
      position: relative;
      border-bottom: 4px solid transparent !important;
      color: #0b4f8a;
      font-weight: 700;
      border-radius: 0
    }

    .ef-nav button[data-tab]:hover {
      background: rgba(233, 242, 251, .75) !important
    }

    .ef-nav button.ef-tab-active {
      background: rgba(233, 242, 251, .95) !important;
      border-bottom-color: var(--dorado) !important;
      color: var(--azul-profundo) !important
    }

    #toastContainer {
      position: fixed;
      top: 80px;
      right: 20px;
      z-index: 9999;
      display: flex;
      flex-direction: column;
      gap: 10px;
      max-width: 400px
    }

    .toast {
      background: white;
      padding: 16px 20px;
      border-radius: 12px;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
      display: flex;
      align-items: center;
      gap: 12px;
      animation: slideIn 0.3s;
      border-left: 4px solid
    }

    .toast.success {
      border-color: #10b981
    }

    .toast.error {
      border-color: #ef4444
    }

    .toast.info {
      border-color: #3b82f6
    }

    .toast.warning {
      border-color: #f59e0b
    }

    @keyframes slideIn {
      from {
        transform: translateX(400px);
        opacity: 0
      }

      to {
        transform: translateX(0);
        opacity: 1
      }
    }

    @keyframes slideOut {
      from {
        transform: translateX(0);
        opacity: 1
      }

      to {
        transform: translateX(400px);
        opacity: 0
      }
    }

    /* ===== MODO OSCURO - Mejorado ===== */
    body.dark-mode,
    body.dark {
      background: #0f1419 !important;
      color: #e8eaed !important;
    }

    body.dark-mode .bg-white,
    body.dark .bg-white {
      background: #1a1f2e !important;
      color: #e8eaed !important;
    }

    body.dark-mode .bg-gray-50,
    body.dark .bg-gray-50 {
      background: #0f1419 !important;
    }

    /* Textos en modo oscuro */
    body.dark-mode .text-gray-600,
    body.dark-mode .text-gray-700,
    body.dark-mode .text-gray-500,
    body.dark .text-gray-600,
    body.dark .text-gray-700,
    body.dark .text-gray-500 {
      color: #9ca3af !important;
    }

    body.dark-mode .text-gray-800,
    body.dark .text-gray-800 {
      color: #e8eaed !important;
    }

    body.dark-mode .text-gray-900,
    body.dark .text-gray-900 {
      color: #f3f4f6 !important;
    }

    /* Bordes en modo oscuro */
    body.dark-mode .border-b,
    body.dark-mode .border,
    body.dark-mode .border-gray-100,
    body.dark .border-b,
    body.dark .border,
    body.dark .border-gray-100 {
      border-color: #2d3748 !important;
    }

    /* Inputs y selects en modo oscuro */
    body.dark-mode input,
    body.dark-mode select,
    body.dark-mode textarea,
    body.dark input,
    body.dark select,
    body.dark textarea {
      background: #2d3748 !important;
      color: #e8eaed !important;
      border-color: #4a5568 !important;
    }

    body.dark-mode input::placeholder,
    body.dark select option,
    body.dark input::placeholder {
      color: #718096 !important;
    }

    /* KPI Cards backgrounds en modo oscuro */
    body.dark-mode .bg-blue-50,
    body.dark .bg-blue-50 {
      background: #1e3a5f !important;
    }

    body.dark-mode .bg-emerald-50,
    body.dark .bg-emerald-50 {
      background: #1a4d3e !important;
    }

    body.dark-mode .bg-rose-50,
    body.dark .bg-rose-50 {
      background: #4a1d2e !important;
    }

    body.dark-mode .bg-amber-50,
    body.dark .bg-amber-50 {
      background: #4a3619 !important;
    }

    /* KPI Colors más brillantes en dark mode */
    body.dark-mode .text-emerald-700,
    body.dark .text-emerald-700 {
      color: #6ee7b7 !important;
    }

    body.dark-mode .text-amber-700,
    body.dark .text-amber-700 {
      color: #fcd34d !important;
    }

    body.dark-mode .text-rose-700,
    body.dark .text-rose-700 {
      color: #fda4af !important;
    }

    body.dark-mode .text-blue-700,
    body.dark-mode .text-blue-900,
    body.dark .text-blue-700,
    body.dark .text-blue-900 {
      color: #93c5fd !important;
    }

    /* Header en modo oscuro - más oscuro pero legible */
    body.dark-mode .ef-header,
    body.dark .ef-header {
      background: linear-gradient(180deg, #0a1929, #051423) !important;
      border-bottom-color: #d4af37 !important;
    }

    /* Nav en modo oscuro */
    body.dark-mode .ef-nav,
    body.dark .ef-nav {
      background: rgba(26, 31, 46, 0.95) !important;
      backdrop-filter: blur(12px);
      border-top-color: #d4af37 !important;
    }

    body.dark-mode .ef-nav button[data-tab],
    body.dark .ef-nav button[data-tab] {
      color: #93c5fd !important;
    }

    body.dark-mode .ef-nav button[data-tab]:hover,
    body.dark .ef-nav button[data-tab]:hover {
      background: rgba(59, 130, 246, 0.1) !important;
    }

    body.dark-mode .ef-nav button.ef-tab-active,
    body.dark .ef-nav button.ef-tab-active {
      background: rgba(212, 175, 55, 0.15) !important;
      border-bottom-color: #d4af37 !important;
      color: #fcd34d !important;
    }

    /* Tablas en modo oscuro */
    body.dark-mode table thead th,
    body.dark table thead th {
      background: linear-gradient(180deg, #1a1f2e 0%, #151923 100%) !important;
      color: #9ca3af !important;
    }

    body.dark-mode table tbody tr:nth-child(odd),
    body.dark table tbody tr:nth-child(odd) {
      background-color: #1a1f2e !important;
    }

    body.dark-mode table tbody tr:nth-child(even),
    body.dark table tbody tr:nth-child(even) {
      background-color: #151923 !important;
    }

    body.dark-mode table tbody tr:hover,
    body.dark table tbody tr:hover {
      background-color: #2a2417 !important;
      box-shadow: inset 0 0 0 1px #d4af37, 0 2px 8px rgba(212, 175, 55, 0.25) !important;
    }

    body.dark-mode .table-container,
    body.dark .table-container {
      border-color: #2d3748 !important;
    }

    /* Badges en modo oscuro - más visibles */
    body.dark-mode .ef-badge--ingresos,
    body.dark .ef-badge--ingresos {
      background: #1a4d3e !important;
      color: #6ee7b7 !important;
      border-color: rgba(110, 231, 183, 0.3) !important;
    }

    body.dark-mode .ef-badge--costos,
    body.dark .ef-badge--costos {
      background: #4a3619 !important;
      color: #fcd34d !important;
      border-color: rgba(252, 211, 77, 0.3) !important;
    }

    body.dark-mode .ef-badge--gastos,
    body.dark .ef-badge--gastos {
      background: #4a1d2e !important;
      color: #fda4af !important;
      border-color: rgba(253, 164, 175, 0.3) !important;
    }

    body.dark-mode .ef-badge--pagado,
    body.dark .ef-badge--pagado {
      background: #1a4d3e !important;
      color: #6ee7b7 !important;
      border-color: rgba(110, 231, 183, 0.3) !important;
    }

    body.dark-mode .ef-badge--pendiente,
    body.dark .ef-badge--pendiente {
      background: #4a3619 !important;
      color: #fcd34d !important;
      border-color: rgba(252, 211, 77, 0.3) !important;
    }

    /* Botones en modo oscuro */
    body.dark-mode button:hover:not(:disabled),
    body.dark button:hover:not(:disabled) {
      background: rgba(59, 130, 246, 0.1) !important;
    }

    /* Scrollbar en modo oscuro */
    body.dark-mode .table-container::-webkit-scrollbar-track,
    body.dark .table-container::-webkit-scrollbar-track {
      background: #1a1f2e !important;
    }

    body.dark-mode .table-container::-webkit-scrollbar-thumb,
    body.dark .table-container::-webkit-scrollbar-thumb {
      background: #4a5568 !important;
    }

    body.dark-mode .table-container::-webkit-scrollbar-thumb:hover,
    body.dark .table-container::-webkit-scrollbar-thumb:hover {
      background: #d4af37 !important;
    }

    /* Modales en modo oscuro */
    body.dark-mode .modal-content,
    body.dark .modal-content {
      background: #1a1f2e !important;
      color: #e8eaed !important;
    }

    /* Toast en modo oscuro */
    body.dark-mode .toast,
    body.dark .toast {
      background: #1a1f2e !important;
      color: #e8eaed !important;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5) !important;
    }

    /* ===== Google Drive Sync Status ===== */
    .gdrive-status {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 4px 8px;
      border-radius: 6px;
      font-size: 11px;
      font-weight: 600;
      transition: all 0.3s ease;
    }

    .gdrive-status.status-offline {
      background: #f3f4f6;
      color: #6b7280;
    }

    .gdrive-status.status-disconnected {
      background: #fef2f2;
      color: #dc2626;
    }

    .gdrive-status.status-connected {
      background: #fef3c7;
      color: #d97706;
    }

    .gdrive-status.status-syncing {
      background: #dbeafe;
      color: #2563eb;
      animation: pulse 1.5s ease-in-out infinite;
    }

    .gdrive-status.status-synced {
      background: #d1fae5;
      color: #059669;
    }

    .gdrive-status.status-error {
      background: #fee2e2;
      color: #dc2626;
    }

    @keyframes pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.6; }
    }

    /* Dark mode para Google Drive status */
    body.dark-mode .gdrive-status.status-offline,
    body.dark .gdrive-status.status-offline {
      background: #2d3748;
      color: #9ca3af;
    }

    body.dark-mode .gdrive-status.status-synced,
    body.dark .gdrive-status.status-synced {
      background: #1a4d3e;
      color: #6ee7b7;
    }

    body.dark-mode .gdrive-status.status-syncing,
    body.dark .gdrive-status.status-syncing {
      background: #1e3a5f;
      color: #93c5fd;
    }

    body.dark-mode .gdrive-status.status-error,
    body.dark .gdrive-status.status-error {
      background: #4a1d2e;
      color: #fda4af;
    }

    .tooltip {
      position: relative;
      display: inline-block
    }

    .tooltip .tooltiptext {
      visibility: hidden;
      width: 220px;
      background-color: #333;
      color: #fff;
      text-align: center;
      border-radius: 8px;
      padding: 8px;
      position: absolute;
      z-index: 1;
      bottom: 125%;
      left: 50%;
      margin-left: -110px;
      opacity: 0;
      transition: opacity 0.3s;
      font-size: 12px
    }

    .tooltip:hover .tooltiptext {
      visibility: visible;
      opacity: 1
    }

    .modal-overlay {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.6);
      z-index: 9998;
      display: flex;
      align-items: center;
      justify-content: center;
      animation: fadeIn 0.2s
    }

    .modal-content {
      background: white;
      border-radius: 16px;
      padding: 24px;
      max-width: 720px;
      width: 92%;
      max-height: 82vh;
      overflow-y: auto;
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3)
    }

    body.dark-mode .modal-content {
      background: #2a2a2a;
      color: #e5e5e5
    }

    @keyframes fadeIn {
      from {
        opacity: 0
      }

      to {
        opacity: 1
      }
    }

    .bg-white.shadow,
    .bg-white.shadow-md,
    .bg-white.shadow-lg {
      border: 1px solid rgba(11, 79, 138, .10)
    }

    .bg-white.shadow-lg {
      box-shadow: 0 10px 28px rgba(8, 59, 102, .12)
    }

    /* ===== KPI Cards - Mejoras Profesionales ===== */
    .card-kpi {
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      border-width: 1px;
    }
    
    .card-kpi:hover {
      transform: translateY(-4px);
      box-shadow: 0 20px 40px -10px rgba(8, 59, 102, 0.2) !important;
    }
    
    .card-kpi h3 {
      font-feature-settings: 'tnum';
      letter-spacing: -0.02em;
    }

    .ef-badge {
      font-size: 12px;
      font-weight: 700;
      padding: 2px 10px;
      border-radius: 999px
    }

    .ef-badge-header {
      display: inline-block;
      font-size: 10px;
      font-weight: 800;
      letter-spacing: 0.1em;
    }


/* ===== Badges (Tipo / Estado) ===== */
.ef-badge{
  display:inline-flex;
  align-items:center;
  font-size:12px;
  font-weight:700;
  padding:2px 10px;
  border-radius:999px;
  border:1px solid rgba(0,0,0,.08);
  line-height:1.35;
  white-space:nowrap;
}
.ef-badge--neutral{ background:#f3f4f6; color:#374151; border-color:rgba(107,114,128,.25); }
.ef-badge--ingresos{ background:#ecfdf5; color:#047857; border-color:rgba(16,185,129,.25); }
.ef-badge--ingreso-pos{ background:#dbeafe; color:#1e40af; border-color:rgba(59,130,246,.25); }
.ef-badge--costos{ background:#fef3c7; color:#92400e; border-color:rgba(251,191,36,.25); }
.ef-badge--gastos{ background:#fff1f2; color:#9f1239; border-color:rgba(251,113,133,.25); }
.ef-badge--inversiones{ background:#eef2ff; color:#3730a3; border-color:rgba(99,102,241,.25); }
.ef-badge--deposito{ background:#f3f4f6; color:#374151; border-color:rgba(107,114,128,.25); }
.ef-badge--pagado{ background:#ecfdf5; color:#047857; border-color:rgba(16,185,129,.25); }
.ef-badge--pendiente{ background:#fef3c7; color:#92400e; border-color:rgba(251,191,36,.25); }

/* ===== Tablas - Zebra Striping y Hover Profesional ===== */
.table-container {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(229, 231, 235, 0.8);
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

table thead th {
  background: linear-gradient(180deg, #f9fafb 0%, #f3f4f6 100%);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4b5563;
  position: sticky;
  top: 0;
  z-index: 10;
}

table tbody tr {
  transition: all 0.15s ease;
  border-bottom: 1px solid #f3f4f6;
}

table tbody tr:nth-child(odd) {
  background-color: #ffffff;
}

table tbody tr:nth-child(even) {
  background-color: #f9fafb;
}

table tbody tr:hover {
  background-color: #fef3c7 !important;
  box-shadow: inset 0 0 0 1px #d4af37, 0 2px 8px rgba(212, 175, 55, 0.15);
  transform: scale(1.002);
}

table tbody td {
  font-size: 13px;
  padding: 14px 16px;
}

/* Alineación de columnas numéricas */
table tbody td:has(> .text-right),
table thead th:has(> .text-right),
td.text-right,
th.text-right {
  text-align: right;
}

/* ===== Inputs y Selects - Focus States Mejorados ===== */
input[type="text"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #d4af37;
  box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.15);
  transform: translateY(-1px);
  transition: all 0.2s ease;
}

/* ===== Botones - Estados Mejorados ===== */
button {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Scrollbar Custom ===== */
.table-container::-webkit-scrollbar,
.custom-scrollbar::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-container::-webkit-scrollbar-track,
.custom-scrollbar::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 10px;
}

.table-container::-webkit-scrollbar-thumb,
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 10px;
  transition: background 0.2s;
}

.table-container::-webkit-scrollbar-thumb:hover,
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #d4af37;
}

/* ===== No Scrollbar Visible (nav horizontal) ===== */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}

.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* ===== Scrollbar visible y delgado para navegación ===== */
.scrollbar-thin::-webkit-scrollbar {
  height: 4px;
}

.scrollbar-thin::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 10px;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background: #d4af37;
  border-radius: 10px;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
  background: #b8962e;
}

.scrollbar-thin {
  scrollbar-width: thin;
  scrollbar-color: #d4af37 #f3f4f6;
}

/* ===== Animaciones de Fade In ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-\[fadeIn_0\.3s_ease-out\] {
  animation: fadeIn 0.3s ease-out;
}

/* ===== Mejoras Responsive ===== */
@media (max-width: 1023px) {
  .card-kpi {
    text-align: center;
  }
  
  .ef-header {
    padding: 1rem !important;
  }
  
  .table-container {
    max-width: 100%;
    overflow-x: auto;
  }
}

@media (max-width: 767px) {
  table {
    font-size: 12px;
  }
  
  table thead th,
  table tbody td {
    padding: 10px 12px;
  }
  
  .card-kpi h3 {
    font-size: 1.75rem;
  }
  
  .ef-nav button[data-tab] {
    font-size: 13px;
    padding: 12px 16px;
  }
}

/* ===== Dark Mode - Tablas ===== */
body.dark-mode table tbody tr:nth-child(odd) {
  background-color: #2a2a2a;
}

body.dark-mode table tbody tr:nth-child(even) {
  background-color: #252525;
}

body.dark-mode table tbody tr:hover {
  background-color: #3a3520 !important;
  box-shadow: inset 0 0 0 1px #8a7731, 0 2px 8px rgba(212, 175, 55, 0.2);
}

body.dark-mode table thead th {
  background: linear-gradient(180deg, #2a2a2a 0%, #252525 100%);
  color: #a0a0a0;
}

body.dark-mode .table-container {
  border-color: #404040;
}

