@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #6C1D8A; /* Morado corporativo */
  --primary-dark: #4A1260;
  --primary-light: #F4E8F7;
  --bg: #F8F9FA;
  --text: #2D3748;
  --text-light: #718096;
  --border: #E2E8F0;
  --sidebar-width: 220px; /* Menú más angosto */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background-color: var(--bg); font-family: 'Montserrat', sans-serif; color: var(--text); -webkit-font-smoothing: antialiased; }

/* HEADER */
header {
  background: white;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
}
.header-brand { display: flex; align-items: center; gap: 12px; }
.header-logo { color: var(--primary); font-size: 24px; }
.header-brand h1 { font-size: 18px; font-weight: 800; color: var(--primary-dark); }
.header-brand p { font-size: 10px; font-weight: 600; color: var(--text-light); letter-spacing: 1px; }

/* MENÚ HAMBURGUESA (Oculto en PC, visible en celular) */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--primary);
  cursor: pointer;
  margin-right: 12px;
}

/* LAYOUT */
.container { display: flex; min-height: calc(100vh - 65px); }
.sidebar { 
  width: var(--sidebar-width); 
  background: white; 
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}
.main-content { flex: 1; padding: 24px; width: 100%; overflow-x: hidden; }

/* BOTONES DEL MENÚ */
.sidebar-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--text-light);
  cursor: pointer; transition: all 0.2s; margin-bottom: 4px; background: transparent; border: none; width: 100%; text-align: left;
}
.sidebar-link:hover { background: var(--bg); color: var(--primary); }
.sidebar-link.active { background: var(--primary-light); color: var(--primary); font-weight: 700; }
.sidebar-link i { font-size: 16px; width: 20px; text-align: center; }

/* TARJETAS Y CONTENEDORES */
.card { background: white; border-radius: 12px; padding: 24px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); margin-bottom: 24px; border: 1px solid var(--border); }
.card-title { font-size: 16px; font-weight: 700; color: var(--primary-dark); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* FORMULARIOS */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 11px; font-weight: 700; color: var(--text-light); margin-bottom: 6px; text-transform: uppercase; }
.form-control {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: 'Montserrat', sans-serif; font-weight: 500; outline: none; transition: border-color 0.2s; background: #FAFAFA;
}
.form-control:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 3px var(--primary-light); }

/* BOTONES */
.btn { padding: 10px 16px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; border: none; transition: all 0.2s; display: inline-flex; align-items: center; gap: 8px; justify-content: center; font-family: 'Montserrat', sans-serif; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: #10B981; color: white; }
.btn-danger { background: #EF4444; color: white; }
.btn-outline { background: white; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-full { width: 100%; padding: 12px; font-size: 14px; }

/* BOTONES TOGGLE (Ingreso/Egreso) */
.toggle-group { display: flex; gap: 8px; margin-bottom: 16px; }
.toggle-btn { flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: #F8F9FA; font-weight: 600; color: var(--text-light); cursor: pointer; transition: all 0.2s; font-size: 13px; }
.toggle-btn.active-ingreso { background: #10B981; color: white; border-color: #10B981; }
.toggle-btn.active-egreso { background: #EF4444; color: white; border-color: #EF4444; }

/* TARJETAS DASHBOARD */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: white; border-radius: 12px; padding: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); border: 1px solid var(--border); }
.stat-label { font-size: 11px; font-weight: 700; color: var(--text-light); text-transform: uppercase; margin-bottom: 8px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text); }

/* TABLAS */
.table-container { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
thead { background: #F8F9FA; border-bottom: 2px solid var(--border); }
th { padding: 12px 16px; font-weight: 700; font-size: 11px; color: var(--text-light); text-transform: uppercase; white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 500; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #F8F9FA; }

/* BADGES */
.badge { padding: 4px 10px; border-radius: 20px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* UTILIDADES */
.flex { display: flex; } .justify-between { justify-content: space-between; } .items-center { align-items: center; }
.gap-2 { gap: 8px; } .gap-4 { gap: 16px; } .mb-4 { margin-bottom: 16px; } .mt-4 { margin-top: 16px; }
.text-right { text-align: right; } .text-center { text-align: center; }
.font-bold { font-weight: 700; } .text-primary { color: var(--primary); }

/* DISEÑO DE DOS COLUMNAS */
.split-layout { display: grid; grid-template-columns: 1fr; gap: 24px; }

/* MODALES */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(4px); }
.modal-content { background: white; border-radius: 16px; width: 100%; max-width: 500px; padding: 24px; box-shadow: 0 20px 40px rgba(0,0,0,0.2); max-height: 90vh; overflow-y: auto; }

/* TOAST */
.toast { position: fixed; top: 20px; right: 20px; z-index: 9999; padding: 12px 20px; border-radius: 8px; color: white; font-weight: 600; font-size: 13px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); animation: slideIn 0.3s ease; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* ============================================================
   ADAPTATIVO PARA CELULARES Y TABLETAS (RESPONSIVE)
   ============================================================ */
@media (min-width: 1024px) {
  .split-layout { grid-template-columns: 350px 1fr; } /* Finanzas en 2 columnas */
}

@media (max-width: 1023px) {
  .menu-toggle { display: block; } /* Aparece el botón de hamburguesa */
  
  .sidebar { 
    position: fixed; 
    top: 65px; /* Debajo del header */
    left: 0; 
    height: calc(100vh - 65px); 
    transform: translateX(-100%); /* Escondido a la izquierda */
    z-index: 40;
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
  }
  .sidebar.open { 
    transform: translateX(0); /* Aparece cuando se hace clic */
  }
  .main-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); } /* 2 tarjetas por fila en celular */
}